ajax表单提交不适用于iPhone Safari [英] ajax form submit not working on iPhone Safari
本文介绍了ajax表单提交不适用于iPhone Safari的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个表格,允许用户选择照片.选择后,将通过ajax自动提交表单(与使用标准提交按钮相反).在所有浏览器中都可以正常运行,但不适用于Safari的移动版本.
I have created a form allowing the user to select a photo. Upon selection, the form is submitted automatically via ajax (as opposed to having a standard submit button). It works fine in all browsers, but it does not work on the mobile version of safari.
我的HTML:
<form id="myForm" action="php/upload.php" method="post">
<input name="uploadedfile" type="file" id="uploadPhotoButton"/>
</form>
我的JavaScript:
My javascript:
$(':file').change(function(){
var formData = new FormData($('form')[0]);
$.ajax({
url: 'php/upload.php', //server script to process data
type: 'POST',
success: uploadComplete,
// Form data
data: formData,
//Options to tell JQuery not to process data or worry about content-type
cache: false,
contentType: false,
processData: false
});
});
在iPhone Safari上,更改处理程序功能很好,但是ajax调用失败.
On iPhone Safari, the change handler function is called fine, but the ajax call fails.
有什么建议吗?
推荐答案
因此,在iOS6中,Safari浏览器似乎会缓存邮寄呼叫...解决方案在这里:
So it appears that in iOS6, safari caches post calls... The solution is here: Is Safari on iOS 6 caching $.ajax results?
这篇关于ajax表单提交不适用于iPhone Safari的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文