jQuery Mobile-提交表单,重定向到页面ID? [英] jQuery Mobile - Submit a form, redirect to a page id?

查看:45
本文介绍了jQuery Mobile-提交表单,重定向到页面ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am setting up a login screen in jQuery Mobile.

提交后.我希望它打到auth.php,它将返回某种会话密钥,然后在索引文件中加载第二页.

Upon submission. I want it to hit the auth.php, which will return a session key of some sort, and then load page #two in my index file.

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

So my main question is: How do I hit auth.php and also load page #two in my index.

<!--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>

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

Then I need it to Load page #two in my Index file. I have mulitple pages in my index..is this the best way to handle this?

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

推荐答案

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

You should redesign so that the auth.php redirects to a view that returns a correct site. JQM will handle it itself wery well.

尽管我不喜欢这个主意,但我仍可以帮助您做到这一点:)

Having said that I can help you do it your way despite I don't like the idea :)

您需要使用$.post()自己发布表单,并在auth.php返回确认后-存储令牌或仅将其留给基于cookie的默认会话机制,然后使用$.mobile.changePage()

You need to post the form yourself with $.post() and after auth.php returns confirmation - store the token or just leave it to default session mechanizm based on cookies and then redirect with $.mobile.changePage()

这篇关于jQuery Mobile-提交表单,重定向到页面ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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