I have a bunch of nested functions returning deferred objects from ajax calls. Here's what my code looks like
function makeCalls() {
    var ajaxDfd1 = $.ajax(...);
    ajaxDfd1.then(function() {
        // want to execute after first call
        var ajaxDfd2 =  $.ajax(...);
        ajaxDfd2.done(function() {
            // want to execute after second call
        });
        return ajaxDfd2;
    });
    return ajaxDfd1;
}
makeCalls().done(function() {
    // stuff here was executed early
});
But my calls are not being executed in the order I intend them to be. Stuff inside makeCalls().done() seems to be called before ajaxDfd2 is actually done.
 
     
     
    