jquery AJAX stopped working with iOS 5.0.1(jquery AJAX 停止使用 iOS 5.0.1)
问题描述
The following piece of logic used to work with both jquery 1.4.4 and 1.7.1 on all mobile devices that we're supporting:
$.ajax({
url: 'http://www.example.com/someurl',
type: 'GET',
dataType: 'text',
timeout: 60000,
success: function(data) {
alert(data);
},
error: function(jqXHR) {
alert(jqXHR.state());
}
});
But with iOS 5.0.1, the above enters the error function alerting rejected
without any actual HTTP requests. It seems that exactly one AJAX request will work before I need to restart my iPhone.
Is this a known jquery / iOS 5.0 problem? How can I debug it? Is there any workaround? I don't know where to start looking.
NOTE: I've noticed on the server side, that instead of GET
requests, OPTIONS
requests are issued. This seems to be a related issue:
http://spin.atomicobject.com/2012/01/20/mobile-safari-on-ios-5-1-unexpectedly-making-cross-origin-resource-sharing-requests/
The link that I provided in the question is actually pointing to the solution. Some of my ajax requests are used to fetch URL's of PDFs which are streamed using
Content-Disposition: attachment; filename="somename.pdf"
Apparently, that causes major issues in iOS 5.0's Safari, breaking the XMLHttpRequest
object (it is not related with jquery). Crazy. Here's the link again:
http://spin.atomicobject.com/2012/01/20/mobile-safari-on-ios-5-1-unexpectedly-making-cross-origin-resource-sharing-requests/
这篇关于jquery AJAX 停止使用 iOS 5.0.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:jquery AJAX 停止使用 iOS 5.0.1


基础教程推荐
- Android:对话框关闭而不调用关闭 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01