当然,我错过了一些简单的...下面是一个简单的表单,我试图提交给PHP脚本。它在PC和Mac上运行良好但不是在iPad上,iPhone等Safari浏览器。我猜想有一个我失踪的移动组件?将表单从iPhone提交到PHP
<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>
我重新发布我的完整代码,并离开了动作URL,这样任何人都可以轻易尝试它。预先感谢您的帮助。代替
你确实在某处包含了jquery,对吧? – Thilo
即使jQuery包含在代码发布中,但我没有看到它如何在PC/Mac上无法正常工作。 – powerbuoy
是的,位于我的代码顶部。添加该操作(并将该方法固定为读取方法=“post”)不起作用。仍然在这里吸吮池塘水): – user1371301