I am using jQuery, and jQuery Mobile to make a mobile app, if that matters that much.
My question is, is it better practice to perform multiple AJAX calls one way or the other?
For example, having a variable that counts all the ajax calls, and then if that variable maxes out, call the complete function such as:
var count = 0
$.ajax({
    //stuff
}).done({
    count++;
    if(count == 5){
        complete();
    }
});
...
or is it better to run them in a chain like:
$.ajax({
    //stuff
}).done({
    $.ajax({
        //stuff
    }).done({
        $.ajax({
            //stuff
        }).done({
            //do complete stuff
        });
    });
});
The application is that multiple API calls need to be made to gather all the information necessary and then manipulate something afterwards. Is there a difference performance wise and is there a "best practice"?
 
     
    