当然我错过了一些简单的东西......下面是我试图提交给 PHP 脚本的简单表单。它在 PC 和 Mac 上运行良好,但在 ipad、iphone 等设备上的 Safari 中却不行。我猜我缺少一个移动组件?
<html>
<head>
<title>Title</title>
<script src="http://code.jquery.com/mobile/1.0a2/jquery.mobile-1.0a2.min.js"></script>
<script type="text/javascript">
$('form').submit(function(){
var postData = $(this).serialize();
$.ajax({
type: 'POST',
data: postData,
url: "http://www.norwichandyork.com/pocketleads/utilities/accounts.php",
success: function(data){
console.log(data);
alert('Your comment was successfully added');
},
error: function(){
console.log(data);
alert('There was an error adding your comment');
}
});
return false;
});
</script>
</head>
<body>
<form method="post" action="http://www.norwichandyork.com/pocketleads/utilities/accounts.php">
<label for="email">
<b>Email</b>
<input type="text" id="email" name="email">
</label>
<label for="fname">
<b>fname</b>
<input type="text" id="fname" name="fname">
</label>
<input type="submit" value="Save">
</form>
</body>
</html>
我重新发布了我的完整代码并留下了操作网址,以便任何人都可以轻松尝试。提前感谢您的所有帮助。:)