2013-07-13 137 views
1

无法从Android 4.2设备中的异步Ajax调用获取响应。每次都会超时异步Ajax调用无法在Android中获得响应

xhr = $.ajax({ 
    type: 'GET', 
    url: url, 
    async: true, 
    contentType: "application/json", 
    timeout : 20000 
}); 
xhr.done(function(data, status, xhr) {//This never gets invoked.}); 

它总是超时。但是如果它的async : false能够在2秒内得到最大响应。

回答

0

这是Android WebView中的一个已知错误 - Async XMLHttpRequest in WebView always returns status 0

使用async:false似乎是唯一的解决方法。

更多讨论here

+1

好的,谢谢你的链接,但让我困惑的是我有2台服务器(一台使用基本的HTTP认证进行安全保护),90%的时间在安全服务器上失败。但它确实会在一段时间内回复。 – GoodSp33d