RESOLVED See answer.
I have a recursive async call that is being resolved at the first call, but I would like to resolve it at the end of the recursivity (where I put 'return "1"'). Any help?
function parent(){
asyncCall().then(function(result){
console.log(result);
});
}
function asyncCall(parameters){
var promises = [];
promises.push(
anotherAsyncFunction(Parameters).then(function (returnedData) {
if (returnedData==1) {
return "1"; //Should resolve here.
} else {
parameters.modify(returnedData);
promises.push(asyncCall(parameters)); //Why resolves here??
}
})
);
return jQuery.when.apply(null, promises);
}
Thanks a lot for your time!