简体   繁体   English

在同一页面上显示表单确认消息:最佳实践

[英]Display form confirmation message in the same page: best practice

I've seen this behaviour in many websites and web applications but I'm not able to find a "clean and standard" way to reproduce it: the user fills in the form, submits it and then, after a successful validation, the form is reloaded with a message on top saying something like "The item has been saved". 我已经在许多网站和Web应用程序中看到了这种现象,但是我找不到一种“干净且标准的”方式来重现它:用户填写表单,提交表单,然后在成功验证之后,将表单会在顶部重新加载一条消息,显示“项目已保存”之类的信息。 No problems so far, what I can't understand is how they keep displaying the confirmation message if that specific page is reloaded, but when the user goes to another page and then returns to the original one (the one containing the form) the message is not there anymore. 到目前为止没有问题,我无法理解的是,如果重新加载该特定页面,他们将如何继续显示确认消息,但是当用户转到另一页面然后返回到原始页面(包含表单的页面)时,该消息不在了。 There seems to be no get or post data, so I'm assuming session variables or cookies are used instead, but how do they know when to keep and when to unset them? 似乎没有获取或发布数据,因此我假设使用了会话变量或cookie,但是它们如何知道何时保留以及何时取消设置它们呢? Or maybe I'm wrong and there is some other way... help me, please! 也许我错了,还有其他方法...请帮助我!

My guess would be that they used a session variable which unsets itself the moment that page is accessed. 我的猜测是,他们使用了一个会话变量,该变量在访问该页面时会自行设置。 So if they try to access it again, they are simply redirected. 因此,如果他们尝试再次访问它,则只需对其进行重定向。

带有表单的页面可能没有任何“未设置”的会话变量,而其他的却有?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM