停止浏览器要求在刷新时重新发送表单数据 [英] Stop browsers asking to resend form data on refresh

查看:20
本文介绍了停止浏览器要求在刷新时重新发送表单数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过 POST 提交了一个表单.我提交了表单,一切都很好,但是如果我尝试重新加载表单在提交后转到的新页面,我会收到您要重新发送数据吗"的提示.消息(火狐).它也可能发生在其他浏览器中,但我不确定.

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!

推荐答案

您需要使用 POST-Redirect-GET 模式.

You need to use the the POST-Redirect-GET pattern.

通过重定向到 GET 请求使您的表单响应.
这样,当用户刷新页面时,只会重新发送GET.

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.

这篇关于停止浏览器要求在刷新时重新发送表单数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆