Using windows.location.replace to refresh a page that does not work with a hash in the url

I have an AJAX call that takes care of some server-side settings (I use this for login, language switches, etc.). If and only if the server parameters are actually changed as a result of this call, I want to update the current page (without re-submitting the POST form data if we are on the page immediately after POST). A simple JS in the AJAX callback will take care of this:

window.location.replace( window.location.toString() ); 

This worked until I started working with anchors. Say my url is like http://www.mysite.com/index/list#someplace and I make the ajax call above ending in window.location.replace then nothing happens. The page does not load. So far tested on FF3.6 and IE7.

+4
source share
1 answer

Have you tried:

 window.location.hash = ''; //if you want to reload with an empty hash window.location.reload(true); //reload the page and bypass the cache 

We use one web page for our web application, and some functions (change of currency, language, etc.) can cause a reboot.

If you want to prevent republishing, you can use a cookie to prevent the server from doing duplicate work.

+6
source

All Articles