I have a situation in which my ajax calls must perform in a particular order. I have used jQuery Deferred objects in other situations, but cannot seem to find a way to make
It's actually quite simple. Though all the AJAX calls are Deferred objects, I still use one for the method itself.
function nestedAjax() {
var dfd = $.Deferred();
$.get("/echo/json/", function(){
console.log("First ajax done.");
$.get("/echo/json/", function(){
console.log("Second ajax done.");
dfd.resolve();
});
});
return dfd.promise();
};