I have an issue with two ajax calls using jQuery 1.4.2. With the first call the server is taking a long time to respond (over 40 sec) and when the 2nd call is fired (which isn't timing out) FireBug tells me the 2nd requests response is downloaded fine but the success event isn't fired. Could someone tell me why this would be? When the first call completes, the 2nd success event is then fired. I don't want to wait for the first call to complete though.
A sample of my code is:
function GetSession() {
var superUrl = "";
superUrl = "http://urltakingalongtimetogivea200response";
// requires authentication
$.ajax({ url: superUrl,
dataType: "jsonp",
timeout: 5000,
jsonpCallback: 'Login',
contentType: "application/json; charset=u开发者_运维问答tf-8",
success: function GotSession(result) {
sessionkey = result.SessionKey;
},
error: function AjaxFailed(result) {
alert("error retrieving session:" + result);
}
});
}
$("#click-me").click(function() {
theQuery = "http://urlreturningresponsequickly";
$.ajax({ url: theQuery,
dataType: "jsonp",
jsonpCallback: 'Results1s',
contentType: "application/json; charset=utf-8",
success: function Success(result) {
alert("this is taking to long to succeed");
// other methods
}
,
error: function AjaxFailed(result) {
alert("error:" + result);
}
});
});
Thanks, Colin.
Not sure but maybe you have to add:
async: true
to ajax calls
精彩评论