Preventing form resubmission

前端 未结 12 952

Page one contains an HTML form. Page two - the code that handles the submitted data.

The form in page one gets submitted. The browser gets redirected to page two. P

12条回答
  •  悲哀的现实
    2020-11-22 09:40

    Directly, you can't, and that's a good thing. The browser's alert is there for a reason. This thread should answer your question:

    Prevent Back button from showing POST confirmation alert

    Two key workarounds suggested were the PRG pattern, and an AJAX submit followed by a scripting relocation.

    Note that if your method allows for a GET and not a POST submission method, then that would both solve the problem and better fit with convention. Those solutions are provided on the assumption you want/need to POST data.

提交回复
热议问题