javascript - jQuery Mobile - 提交表单,重定向到页面 ID?

标签 javascript jquery jquery-mobile

我正在 jQuery Mobile 中设置登录屏幕。

提交后。我希望它能够访问 auth.php,它将返回某种 session key ,然后在我的索引文件中加载第 #two 页。

所以我的主要问题是:我如何点击 auth.php 并在我的索引中加载页面#two。

<!--index.php-->
<form action="auth.php" method="post">
  <div class="ui-body ui-body-b">
    <input type="text" name="name" id="name" value="" class="ui-input-text ui-body-null ui-corner-all ui-shadow-inset ui-body-c" placeholder="Username">
    <input type="password" name="name" id="name" value="" class="ui-input-text ui-body-null ui-corner-all ui-shadow-inset ui-body-c" placeholder="Password"> 
    <fieldset class="ui-grid-a"> 
      <div class="ui-block-a"><button type="reset" data-theme="d">Reset</button></div> 
      <div class="ui-block-b"><button type="submit" data-theme="a">Login</button></div> 
    </fieldset> 
  </div>
</form>

然后我需要它来加载索引文件中的第二页。我的索引中有多个页面..这是处理此问题的最佳方法吗?

<!-- Start of second page: #two in index.php--> 
<div data-role="page" id="two" data-theme="a"> 

最佳答案

您应该重新设计,以便 auth.php 重定向到返回正确站点的 View 。 JQM 本身会处理得很好。

话虽如此,尽管我不喜欢这个主意,但我可以帮助你按照你的方式去做:)

您需要使用 $.post() 自行发布表单,并在 auth.php 返回确认后 - 存储 token 或将其保留为基于 cookie 的默认 session 机制,然后使用 $.mobile.changePage()

关于javascript - jQuery Mobile - 提交表单,重定向到页面 ID?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7478240/

相关文章:

javascript - useState 和 useEffect 有什么区别?

javascript - jQuery 添加无标记的 CSS 属性

javascript - 视差滚动底部

javascript - jQuery/JavaScript 在切换按钮查询上显示/隐藏事件

c# - MVC 4 razor 数据注释只读

javascript - 如何使用 jquery mobile css 类自定义文本框

javascript - .checkboxradio ('refresh' )问题,无法与禁用的预加载字段一起使用

javascript - 如何在 Bootstrap 中连续获得相同大小的列?

javascript - Nodejs 从 Promis 返回结果并将变量作为函数异步分配

javascript - 如何禁用图像谷歌自定义搜索引擎 cse 上的链接?