title: Promise with Async Ajax call
body: <p>I am trying to make multiple async Ajax calls and want to do some action when all ajax calls are completed. So I am trying to use jquery promise functionality, but it seems like it is calling $.done function before the ajax calls are successful.</p>
  
  <p>Below are my codes:</p>
  
  <pre><code>    pool = {a: 1, b: 2};
      for(var camp in pool){
          promises.push(parseFile(camp));
      }
  
      $.when.apply($, promises).done(function() {
          console.log("All jobs finished");
      });
  
      function parseFile(fname)
      {
          console.log(fname +" call");
          $.ajax({
              url: "data/" + fname + ".txt",
              dataType: "text"
          })
          .done(function(data) {
              console.log(fname + " done");
          });
      }
  </code></pre>
  
  <p><strong>Console Log:</strong></p>
  
  <p>a call<br>
  b call<br>
  All jobs finished <strong>// THIS SHOULD HAVE BEEN CALLED AT THE END</strong><br>
  a done<br>
  b done<br></p>