Im using jQuery AJAX Calls to a webservice. The calls have to be chained. Based on the solution of https://stackoverflow.com/a/995648/296575 I created an AJAX queue.
function ajaxQueue(step) {
switch(step) {
case 0: $.ajax({
type: "POST",
url: "url",
data: SoapRequest1,
contentType: "text/xml",
complete: storeData1
}); break;
case 1: $.ajax({
type: "POST",
url: "url",
data: SoapRequest2,
contentType: "text/xml",
complete: storeData2
}); break;
case 2: $.ajax({
type: "POST",
url: "url",
data: SoapRequest3,
contentType: "text/xml",
complete: storeData3
}); break;
}
}
//start ajaxQueue
ajaxQueue(0);
function storeData1(xmlHttpRequest, status)
{
updateData1(xmlHttpRequest.responseXML);
ajaxQueue(1);
}
function storeData2(xmlHttpRequest, status)
{
updateData2(xmlHttpRequest.responseXML);
ajaxQueue(2);
}
function storeData3(xmlHttpRequest, status)
{
updateData3(xmlHttpRequest.responseXML);
}
Now I have the following issue: If the function is executed, only the first case returns the correct XML from the webservice. The second and third calls lead to an error. (parseerror, data is null).
The calls are cross domain, which is supressed by:
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
If I add async:false to each call, all of them are executed correctly. If I change the order of the calls, always the first one is executed correctly.
Can anyone help me with this one? Or tell me If you need more information.
Thank you!