I have a single function making ajax calls to retrieve data. The issue I'm having is making nested ajax calls where one call depends on other and $.wait().then() is not really working. Is there any solution to my issue. Here is an example...
function _Ajax(params){
if(params == ''){
alert('no post params');
return;
}
var xdata;
$.ajax({
type: "POST",
url: "/xml/",
async: false,
data: params,
dataType: "xml",
success: function(xml){
xdata = xml;
},
error: function() {
alert("An error occurred while processing XML file. Params:" + objToString(params));
}
});
return xdata;
}
function A(a,b){
_Ajax({a:a,b:b});
}
function B(a,b,c){
_Ajax({a:a,b:b,c:c});
}
function C(a,b){
A(a,b);
B(a,b);
}
function D(a,b){
_Ajax({a:a,b:b});
}
function E(){
$.when(C(a,b)).then{function(){ D(a,b);});
}
I also tried to change async to true and it completely fails without returning any data. Thanks