title: Is there any way of forcing a set of jquery ajax calls into a queue?
body: <p>I have an array of data (arrData) which I loop around (10 elements), calling an ajax request on each. As it stands at the moment each ajax call is made in parallel. This means the server receives 10 calls all at once and sends back the data in whatever order it calculates each in. To relieve the server slightly I want to now queue my calls. Therefore, when one set of data is received by ajax it calls the next lookup. Is there any way method of doing this built in to jquery or should I hack my loop and add a recursive callback to each?</p>
  
  <pre><code>$.each(arrData, function(k,v) {
      $.getJSON(lookupPath,
          { key:k, val:v },
          function(data) {
              console.log(data); //loopback here?
          }
      );
  });
  </code></pre>
  
  <p>UPDATE: I went with the following (as suggested by Scott M.) to get this done:</p>
  
  <pre><code>function doLookup() {
      if(k &lt; arrData.length) {
          var v = arrData[k];
          $.getJSON(lookupPath,
              { key:k, val:v },
              function(data) {
                  console.log(data);
                  k++;
                  doLookup();
              }
          );
      }
  }
  
  var k = 0;
  doLookup();
  </code></pre>