Taho
Taho

Reputation: 833

refresh page in POST and keep all parameters using javascript

how can I refresh a page using javascript and keep all the parameters in the POST method?

Upvotes: 0

Views: 4171

Answers (1)

bobince
bobince

Reputation: 536399

location.reload();

Will do that, but if the current page is the direct response to a POST request then the user will get a browser dialogue confirming the re-POST before the page reloads.

If that's no good you would have to create a new <form> element with method="post" and action pointing to the current URL. You would have to do this from the server-side to duplicate all the POSTed parameters as <input type="hidden"> (and file uploads can't be replicated).

Depending on what you are doing, you may be able to use the PRG model to stop most pages being POST responses, allowing you to refresh without prompting.

Upvotes: 2

Related Questions