检索POST方法表单传递的值 [英] Retrieving values passed by POST method form

查看:117
本文介绍了检索POST方法表单传递的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在表单中的 POST 方法遇到了一些问题.我有一个页面A,其中的表单具有 POST 方法,当我提交表单时,它会转到页面b.

I am facing some problem with POST method in form . I have a page A with a form with POST method and when i submit form it goes to page b .

现在的问题是,当我刷新时 弹出我不想来的警报.我正在使用HTML和Javascript.

Now problem is that when i do a refresh it pop ups a alert which i don't want to come . I am using HTML and Javascript.

有什么方法可以处理此刷新吗?

Is there any way to handle this refresh?

我能想到的一种方法是在页面b上动态创建一个隐藏的表单,并在字段中填充值,并且每次刷新时,它都会提交该隐藏的表单.

One way that i can think of is to dynamically create a hidden form on page b with the values populated in fields and for every refresh it just submits that hidden form .

请提出建议,并让我知道是否还有其他一些整洁的方法.提前致谢! 基本上我在AS400平台上使用CGIDEV2.因此,提交页面a上的输入表单时,它会调用abc.pgm来写页面b. Cgidev2在各节中编写html.它将先写入/TOP部分,然后是/REFRESHFORM.这些值将填充在abc.pgm中.

Please suggest and let me know if there is some other neat work around. Thanks in advance! Basically i am using CGIDEV2 on AS400 platform . So when input form on page a is submitted it call abc.pgm which writes page b. Cgidev2 writes html in sections . It will write /TOP section then /REFRESHFORM. and these values will be populated in abc.pgm .

PAGE a
    /FORM
        <form name="input" action="abc.pgm" method="POST">
    Username: <input type="text" name="user"><input type="submit" value="Submit"></form>
Page b 
    /TOP
    -----------------
    -------------- 
    /REFRESHFORM
    <form name="refreshinput" action="abc.pgm" method="POST">
    Username: <input type="text" name="user"><input type="submit" value="Submit"></form>

推荐答案

您要避免出现确认重新提交表单"警报?通常的方法是使用 POST/重定向/GET 模式:页面A会将表单过帐到服务器,服务器处理数据,然后向用户发出3xx重定向,触发对B页的GET请求.因此,随后重新加载B页将只是通常的钻取操作,即没有警报消息

You're trying to avoid the "confirm form resubmission" alert? The usual way to do that is using the POST/Redirect/GET pattern: page A would POST the form to the server, the server processes the data and then issues a 3xx redirect back to the user, triggering a GET request for page B. Thus subsequent reloads of page B would just be the usual drill, i.e. no alert message.

这篇关于检索POST方法表单传递的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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