>我有一个这样的html:
<!doctype html>
<html manifest="">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"></script>
</head>
<body>
<div data-role="page" id="Find">
<div data-theme="b" data-role="header" data-position="fixed">
<h3>test</h3>
</div>
<div data-role="content">
<form action="handler.php" id="findForm" >
<div data-role="fieldcontain">
<fieldset data-role="controlgroup">
<label for="textinputf1"> keyword: </label> <input id="textinputf1" name="keyword" placeholder="" value="" type="text" />
</fieldset>
</div>
<input type= "submit" data-theme="g" value="Find" />
</form>
</div>
</div>
<div data-role="page" id="Results">
<div data-theme="b" data-role="header" data-position="fixed">
<h3>Results</h3>
</div>
<div data-role="content">
<ul data-role="listview" data-filter="true">
<li><a href="">HEllo</a></li>
<li><a href="">Bye</a></li>
</ul>
</div>
</div>
</body>
</html>
一个处理程序.php如下所示:
<?php
//...
if( let's say false ) {
header("location:.");
}else{
header("location:./#Results");
//header("Refresh:0;url=/application/test/#Results");
}
使用标题+刷新或使用标题+位置,当我提交表单时,我在 url 栏中看到以下内容: .../handler.php?keyword=test
但我没有被重定向,如果我刷新页面(从 url 栏或 F5 按回车键),那么我会进入 #Results,但不是自动的
知道如何解决这个问题吗?
jquery Mobile可能使用ajax来处理你的表单。您应该切换表单的 ajax 处理
j查询移动表单示例
还要在您的位置放置一个空间
Location: whereyouwanttogo
在不刷新的情况下查看传递的参数的方法是输入 data-ajax="false"
如果你想使用 ajax,不要直接调用 url。使用 AJAX 调用这些,并根据响应重定向到 JavaScript 的帮助下 #Results。