【问题标题】:Multiple web service requests from single page in html来自 html 中单个页面的多个 Web 服务请求
【发布时间】:2014-01-23 04:31:53
【问题描述】:

我正在尝试在单个页面中提交三个表单。但我停留在某一点上。 我想在第一个表格中验证手机号码。然后在最终表单提交中使用该手机号码

我已尝试在单个表单中使用此功能,但是如何发送 Web 请求以使用验证移动按钮发送验证密码。

我有这样的三种形式,

    //First Form Take Mobile Number, web service will send verification Pin as reply to this action
    <form name="PhoneVerification" action="url to phone verification web service" >
    Phone Number: <input type="text" name ="number" id="phone">
    <input type="submit" name ="submit1" id="submit1">Verify Mibile Number</input>
    </form>

//Second Form verifies pin Locally which is sent by first service
    <form name="PinVerification" action="verify pin came from previous web service">
    Verification Pin(Sent on Mobile Number): <input type="text" name ="pin" id="pin">
    <input type="submit" name ="submit2" id="submit2">Verify Pin</input>
    </form>

//Third Form Will Take Mobile Number Previously Entered. and email/password and Complete Signup
    <form action="web service call to complete signup">
    Email: <input type="text" name ="email" id="email">
    Password: <input type="text" name ="pass" id="pass">
    PasswordAgain: <input type="text" name ="passAgain" id="passAgain">
    <input type="submit" name ="submit3" id="submit3">Complete Signup</input>
    </form>

问题是我无法获取电话号码的值,因为在提交表单后刷新页面。

我阅读了一些关于使用 AJAX 的帖子,但是在这种情况下我该如何使用 Ajax。 我怎样才能做到这一点。使用 AJAX,或使用 PHP。

【问题讨论】:

  • 使用本地存储或会话。
  • @CJRamki 本地存储你的意思是 html 或数据库中的标签?
  • 您的意思是在使用 java 脚本提交的第一个表单上设置 cookie。好吧,我一定会尝试的
  • 是的... cookie 中的第一个表单提交存储编号。并以另一种形式从 cookie 中获取价值并加以利用。完成所有工作后不要忘记删除 cookie w3schools.com/js/js_cookies.asp
  • @CJRamki 将其发布为答案。它确实帮助了我。我使用 Session 和 AJAX 从同一页面提交多个表单

标签: php jquery html ajax web-services


【解决方案1】:
    Id must be unique in your html page. In above code id="phone" be present in first to forms. the second form in pinVerfication right but there is an same id = "phone" . please change it and make an another try. third form have also same problem

    //Second Form verifies pin Locally which is sent by first service
        <form name="PinVerification" action="verify pin">
        Verification Pin(Sent on Mobile Number): <input type="text" name ="number" id="pin">
        <input type="submit" name ="submit2" id="submit2">Verify Pin</input>
        </form>

/Third Form Will Take Mobile Number Previously Entered. and email/password and Complete Signup
    <form action="web service call to complete signup">
    Email: <input type="text" name ="email" id="email">
    Password: <input type="text" name ="pass" id="pass">
    PasswordAgain: <input type="text" name ="passAgain" id="passAgain">
    <input type="submit" name ="submit3" id="submit3">Complete Signup</input>
    </form>

【讨论】:

    【解决方案2】:

    您可以使用cookiessessions 来完成此任务。

    如果您只想使用 javascript 来执行此操作,则可以使用 cookie。你可以从w3schools得到最好的参考

    您可以使用 php 之类的服务器端脚本并使用 ajax 来实现。 在这种情况下,您可以使用session

    cookiessession 中的第一个表单提交存储编号。在另一种形式中,您可以从cookiesession 获得该值并加以利用。

    注意:完成所有工作后不要忘记删除cookiessession

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多