我一直在使用phonegap 开发一个android 应用程序。在应用程序中,我使用 xmlrpcrequest 请求。有时当我发出请求时,可能是由于连接速度慢,请求超时,我收到以下错误
E/WebUrlLoaderClient(574):第 0 次尝试 10 秒后同步请求超时
有没有办法“捕捉”这个错误,或者可能增加超时时间?
I have this same problem since I updated to phonegap 2.8.1, what version are you using? It does not seem to listen to the ajax argument timeout at all:
var dataObj = { 'value': whatever'};
//navigator.notification.alert(JSON.stringify(dataObj));
$.ajax({
type: 'POST',
url: url,
async: false,
data: JSON.stringify(dataObj),
dataType: 'json',
timeout: 25000,
contentType: 'application/json; charset=utf-8',
crossDomain: true,
xhrFields: {
withCredentials: true
},
beforeSend: function(xhr) {
xhr.setRequestHeader("Authorization", "Basic " + Base64.encode(username + ":" + password));
},
success: post_succes,
error: function(xhr, status, errThrown) {
var out = "<br>Error status " + status;
out += "<br>Error request status text: " + xhr.statusText;
out += "<br>Error request status: " + xhr.status;
out += "<br>Error request response text: " + xhr.responseText;
out += "<br>Error response header: " + xhr.getAllResponseHeaders();
navigator.notification.alert(out);
}
});
I also tried to set this value in the java main: (I know this is not the right property... but desperate figuring it out...)
super.setIntegerProperty("loadUrlTimeoutValue", 25000);
it keeps sticking to the 10 seconds....