, JavaScript, jQuery ajax. POST . . , . switch, :
var callback = function(sCallIdentifier, callbackParameters){
switch(sCallIdentifier){
case "ajaxOne":
doYourStuff(callbackParameters);
ajaxTwo(function(newCallbackParameters){
callback("ajaxTwo", newCallbackParameters);
});
break;
case "ajaxTwo":
doYourStuff(callbackParameters);
ajaxThree(function(newCallbackParameters){
callback("ajaxThree", newCallbackParameters);
});
break;
case "ajaxThree":
doYourStuff();
break;
}
});
If this is not a good idea, please let me know. As I said, I'm not a JavaScript expert, but I worked fine for me.
Best, Renee
Edit:
After some time, I found out that Promises is a much better approach to solve this problem.
source
share