Sending parameters via URL during reboot

I am making an ajax request and in the success callback I want to refresh the page to reflect the changes. I am trying to pass parameters to the same page as refreshing this page.

The url looks something like this:

http://localhost:8080/details#component/12 , to which I add the parameter, as follows.

 window.location.href += "?code=approved"; window.location.reload(); 

This works in Firefox, but not in IE, can you help here?

Chris.

+4
source share
3 answers

Try using them for IE:

 window.location.reload(false); // To get page from cache window.location.reload(true); // To get page from server 
+1
source

Hash problem; you add your data to the URL fragment (part after #). The fragment is not sent to the server, i.e. The URL does not change, so you no longer need to request a page. Try manually adding "#some_text" to your browser URL and see what happens;)

Try something like this:

 var newloc = document.location.href; if(document.location.hash){ // remove fragment newloc = newloc.substr(0, newloc.indexOf(document.location.hash)); } newloc += document.location.search ? ";" : "?"; // prevent double question mark newloc += 'code=approved'; // append fragment back to url 
+1
source

if window.location.hash empty, you cannot assign location.href a new value without using the correct function (at least checked on chrome).

try window.location.replace :

 if (!window.location.hash) { window.location.replace(window.location.href + "?code=approved") } 
+1
source

Source: https://habr.com/ru/post/1413306/


All Articles