Stop browsers asking to resend form data on refresh
I have a form submission via POST. I submit the form, and all is well, however if I try to reload the new page that the form goes to after submission, I get the "Do you want to resend data" message (Firefox). It might happen in other browsers too, but I'm not sure.
Is there a way to stop this message popping up so I can go ahead and refresh the page? It's not good for production environments - users may submit the same form twice!
Solution 1:
You need to use the the POST-Redirect-GET pattern.
Make your form respond with a redirect to a GET request.
This way, when the user refreshes the page, it will only resend the GET.
Solution 2:
An easy way after response.sendRedirect
is to reload the page in this way:
window.location.href = window.location.pathname;
It works for me.