My script needs to handle several ajax requests. Here is a simplified version:
function request(variable){
    $.ajax({
        // call config
    }).done(function(data){
        // treatment of returned data
        // returning TRUE (ok) or FALSE (errors)
    }).fail(function(e){
        // generating error message
    });
}
I need to make several calls:
request(variableA);
request(variableB);
request(variableC);
Requests are performed simultaneously and work well, but I don't know when the process is finished. And I can't display returned values.
Some discussions suggest to use when().
  $.when(request(variableA), request(variableB), request(variableC))
   .done(function(resultA, resultB, resultC) { 
         alert("Finished!");
         //results available
    });
Using this code, alert seems to be performed at the very beginning of the process instead of waiting for completion...
What would be my best option ?