title: When all AJAX requests complete
body: <p>I have an ajax request that grabs some data and then splits it up into an array.  The array length is variable.</p>
  
  <pre><code>  var ajax1 = $.ajax({
      url: 'myurl.php',
      type: "GET",
      dataType: "jsonp",
      success: function (data) {
  
        //create an array
  
      }
  
    });
  </code></pre>
  
  <p>Once I have the array, I want to loop through it and in each iteration run another AJAX request.  I put it inside a $.when to make sure the initial ajax request was complete:</p>
  
  <pre><code>  $.when(ajax1).done(
      function() {
  
        for (i = 0; i &lt; array.length; ++i) {
  
          $.ajax({
            url: 'anotherurl?=' + myarray[i],
            type: "GET",
            dataType: "jsonp",
            success: function (data) {
  
              //do stuff here
  
            }
          });
  
        }
  
      }
    )
  </code></pre>
  
  <p>My question is, how can I get a message box to pop up when the for loop has completed all the AJAX requests? A simple <code>alert('complete')</code> at the end of the loop won't work as the AJAX is done async.</p>