gpt4 book ai didi

javascript - 从 iPhone 向 PHP 提交表单

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:51:39 27 4
gpt4 key购买 nike

当然,我遗漏了一些简单的东西...下面是我尝试提交给 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>

我已经重新发布了我的完整代码并留下了操作网址,以便任何人都可以轻松尝试。在此先感谢您的所有帮助。 :)

最佳答案

解决了!不确定它是 Xcode 还是 PhoneGap 问题,但您必须将您从应用程序访问的每个域列入白名单。虽然我确实将我的域列入白名单,但它仍然不起作用。我在检查编译错误日志时发现了这一点。我发现了这个:http://www.prosoxi.com/2011/10/08/xcode-phonegap-white-list-rejection/并将 *.mydomain.com 添加到白名单,现在一切正常。感谢大家的意见。

关于javascript - 从 iPhone 向 PHP 提交表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10423606/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com