Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

window.location.href and location.reload() does not load updated page from Server

I have a form being updated on AJAX call.

After Ajax call is succeeded, I want to reload that same page to reflect new changes.

I have used location.reload() and window.location.href after AJAX call is succeeded, a proper RELOAD on browser is performed but the form shows the old data, not new.

If I reload page using browser's reload button the newly updated data is shown.

But how do I reload a page properly using jQuery?

like image 672
Umair Ayub Avatar asked Jul 13 '16 14:07

Umair Ayub


People also ask

Does window location href reload the page?

location. reload() reloads the current page with POST data, while window. location. href='your url' does not include the POST data.

What does Window location reload () do?

The location. reload() method reloads the current URL, like the Refresh button.

How do you refresh the current page in HTML?

Window location.reload() The reload() method reloads the current document. The reload() method does the same as the reload button in your browser.

How do I refresh a page using anchor tag?

After you set the specified URL into location, issue window. location. reload(true) . This will force browser to reload the page.


1 Answers

The method reload(forcedReload) accepts a Boolean flag, which, when it is true, causes the page to always be reloaded from the server. If it is false or not specified, the browser may reload the page from its cache.

Please try:

// Reload the current page, without using the cache
document.location.reload(true);
like image 165
Ismail RBOUH Avatar answered Oct 19 '22 23:10

Ismail RBOUH