I have a button which loads after a ajax call , on clicking i want to reload the page (like i press f5)
I tried
$( ".delegate_update_success" ).click(function() {
location.reload();
});
but it does a simple refresh, but my page does not makes a new request to get the contents. It should happen just like I am entering URL to get that page.
Method 1: Using the location. reload(): The location. reload() method reloads the current web page emulating the clicking of the refresh button on the browser.
On Refresh/Reload/F5: If user will refresh the page, first window. onbeforeunload will fire with IsRefresh value = "Close" and then window. onload will fire with IsRefresh value = "Load", so now you can determine at last that your page is refreshing.
Window location. The reload() method reloads the current document. The reload() method does the same as the reload button in your browser.
You should use the location.reload(true)
, which will release the cache for that specific page and force the page to load as a NEW page.
The true
parameter forces the page to release it's cache.
If your button is loading from an AJAX call, you should use
$(document).on("click", ".delegate_update_success", function(){ location.reload(true); });
instead of
$( ".delegate_update_success" ).click(function() { location.reload(); });
Also note the true
parameter for the location.reload
function.
Use document.location.reload(true)
it will not load page from cache.
You can also use window.location.href=window.location.href;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With