Here's the Form in Question为什么本页上的表单只能工作一次?
我是jQuery Mobile的新手,所以我怀疑这个问题与JS jQuery Mobile运行有关。
该表格似乎表现出预期的第一次通过。随后的提交文件似乎什么也没有做,而且每次提交之后也有一些轻微的恼人的动画。
编辑:您可以输入“测试”的示例查询。
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Phone Price Look-up</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css" />
<style>
/* App custom styles */
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js">
</script>
<script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js">
</script>
</head>
<body>
<div data-role="page" id="page1">
<div data-theme="a" data-role="header">
<h3>
Price Finder
</h3>
</div>
<div data-role="content">
<div id="search-form-container">
<form name="search-form">
<div data-role="fieldcontain">
<fieldset data-role="controlgroup">
<label for="search_term">
Enter Model Number:
</label>
<input id="search_term" placeholder="" value="" type="text" />
</fieldset>
</div>
<input id="search-form-submit" type="submit" data-theme="b" value="Submit" />
</form>
</div>
</div>
<div data-theme="a" data-role="footer">
<h2>
www.thephonerecyclers.com
</h2>
</div>
</div>
<script>
$(document).ready(function() {
$.mobile.ajaxLinksEnabled = false; // don't really know what this does.
$('#search-form-submit').click(function() {
var searchTerm = $('#search_term').val();
$.ajax({
type: 'POST',
url: 'ajax/search.php',
data: {search_term: searchTerm},
success: function(response) {
response = JSON.parse(response);
if (!response.success) {
alert('no phone found');
} else {
var phoneInfo = JSON.parse(response.response);
alert(phoneInfo[0].manufacturer + ' ' + phoneInfo[0].name + ' (' + phoneInfo[0].model_no + ')' + '\n$' + phoneInfo[0].price);
}
},
error: function() {
//handle error
alert('error doing ajax, mate');
}
});
});
});
</script>
</body>
</html>
在这里发布您的代码。我不点击问题中的链接。 – 2012-03-27 17:54:35
即使是第一次,它也不适合我。我正在使用Chrome。 – 2012-03-27 17:54:59
什么不起作用?每次行为看起来都一样。 FireBug每次都会显示请求和响应。 – David 2012-03-27 17:55:20