I am currently facing a little problem with HTTP post forms and history pushstate.
When my user submits a POST form in example.com/page-1
and then clicks on a link within this page, they are redirected to example.com/page-2
with a history.pushstate. The JS script just changes the current url, pushes the old to the history, and then displays the new content. This works perfectly fine for me.
The problem: Once the user is on example.com/page-2
and manually refreshes the page (ctrl+r or refresh button), Chromes prompts the user to submit the form again; but the form was actually in example.com/page-1
and there is no reason to asked it again in this "new" page.
Is there a way to clear all the previously-submitted data in javascript on the popstate change to prevent repost prompt from the browser? Or am I missing something with my history states? Or is it something currently not implemented by the browser well yet?
I only tested it with chrome since I don't implement pushstate with other browsers.