iPhone Mobile Safari 上的 AJAX 响应为空
我们运行一项 Web 服务,并为其构建了一个网站作为 Web 应用程序和使用 PhoneGap 的 iPhone 应用程序。我们在网页和 PhoneGap 页面中使用 ajax 来与我们的服务器进行通信。一切似乎都很好,直到我们的一台测试设备(iPhone 3G、iOS 4.3.2)不断从 XMLHttpRequest 获取空响应正文。
我们在 Web 应用程序中使用 jQuery.ajax,并在 PhoneGap 应用程序中使用 XMLHttpRequest 实现了类似的功能。我们首先发现 PhoneGap 应用程序无法在“可怜的”iPhone 3G 上登录我们的服务器,然后在其 Mobile Safari 上尝试该 Web 应用程序,发现同样失败。然而,其他网站(Google、GMail、Twitter 等)与其 Mobile Safari 配合使用没有任何问题,并且我们的其他设备(甚至所有 iPhone 4.x 模拟器)都没有此问题。
我们调试了代码,发现从 XMLHttpRequest 获取的responseText 格式错误。当我们将其作为 JSON 解析为对象时,结果是一个空字符串 ("")。但是,状态代码是正确的。
有人听说过这样的问题吗?我们没有另一部搭载 iOS 4.3.2 的 iPhone 3G,因此我们很难确定这是否是操作系统方面的问题。
We run a web service, and have built for it a website as a web app and an iPhone app using PhoneGap. We use ajax in both our web pages and PhoneGap pages to communicate with our server. All seems fine until one of our testing devices (iPhone 3Gs, iOS 4.3.2) constantly get empty response body from the XMLHttpRequest.
We use jQuery.ajax in the web app, and implemented a similar function in the PhoneGap app using XMLHttpRequest as well. We first found the PhoneGap app fails to sign in to our server on the 'wretched' iPhone 3Gs, then tried the web app on its Mobile Safari and found that fails the same. However, other websites(Google,GMail,Twitter,etc.) work with its Mobile Safari without any problem, and NONE of our other devices (even all iPhone 4.x Simulators) has this problem.
We debugged our code and found that the responseText we get from the XMLHttpRequest is malformed. When we parse it as JSON into an object, the result is an empty string (""). However, the status code is correct.
Is there anyone who has heard of such problem? We don't have another iPhone 3Gs with iOS 4.3.2, so it's difficult for us to determine if this is an operating-system-side issue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是否可能与此问题有关: https://github.com/jquery/jquery-移动/问题/2521?如果是这样,结论似乎是该版本的 Safari 存在问题。
即使该错误不相同,您也可以尝试更改/删除链接的 rel 属性并禁用 JQuery 的 PushState 以进一步缩小问题范围。
如果您还没有尝试过,我建议您获取该页面的本地副本并尽可能减少其内容,以尝试找到最小的犯罪行为,即仍然存在问题的页面的最小版本。
Is it possible it's related to this issue: https://github.com/jquery/jquery-mobile/issues/2521? If so, the conclusion seems to be that it's an issue in that version of Safari.
Even if that bug isn't identical, you could try changing / removing the rel attribute of your link and disabling JQuery's pushState to narrow the problem down even further.
If you haven't already tried it, I'd suggest taking a local copy of the page and reducing its content as much as you can to try to find the minimal criminal, i.e. the smallest version of the page that still exhibits the problem.
我看到很多与你类似的问题,这可能对你有帮助
https ://discussions.apple.com/thread/2499350?start=15&tstart=0
移动 safari 的 AJAX 响应太大?
jQuery Ajax 响应:在浏览器中工作,在移动设备上为空
祝你好运。! :)
I seen a lot of issues similar to you ,, this maybe help you
https://discussions.apple.com/thread/2499350?start=15&tstart=0
Too large an AJAX response for mobile safari?
jQuery Ajax Response: Works in Browser, Null on Mobile Device
Goodluck.! :)