Page reload via javascript: avoid postback warning

I start reloading the page through javascript using the following:

window.location.reload(true); 

However, in some cases (of the previous postback), the browser tells me the following warning: "To display the web page again, the web browser must resend the information that you previously sent ...".

Is there a way to avoid this post and just do a postback anyway, because it can confuse users? If I need to reload the page in another way, so be it.

+4
source share
6 answers

I don't think there is a way to do postback without message when you do a reboot.

Btw, why do I need a reboot? If it sends the POST information again, I suggest you manually send the data via ajax or a hidden submit form using javascript.

+2
source

if you want to refresh the page without taking into account mail data, and not just for postback.

 window.location = window.location.href; 
+6
source

The request you are trying to do again is the POST request, so a warning. You can either make sure that you only reload the resources received through GET requests, or, alternatively, send a hidden <form> using the POST method (and thus simulate a reload that will not be cached).

As you probably already know, the warning is related to idempotence (lack of side effects) in HTTP verbs. GET (among others) (should be at least) considered idempotent, while POST requests allow changes on the server. Therefore, the client must ask the user to confirm that he / she intends to perform the action again.

+2
source

The only way is to stop it from re-setting the parameters. using window.location = window.location

+1
source

One way to store state data on a page is with fragment identifiers in a URL, for example. # filter1, # filter2, and then using the convenient hashchange plugin for jQuery to execute code (i.e. reload the corresponding part of the page with the latest results) when the URL fragment changes through the onhashchange event. This is also good because various states can be bookmarked and cached.

http://benalman.com/projects/jquery-hashchange-plugin/

0
source

After:

 mysql_query("insert into table (id_item, quantity, cost) values($m, '$amount', '$cost')"); 

Placed:

 header("Location: index.php"); 

Then reload the page using jquery and you will not get the warning "... the web browser should send the information ...".

0
source

All Articles