title: jQuery AJAX calls in for loop
body: <p>I'm new to using AJAX, and I'm writing a userscript that will process a bunch of links on a page and make AJAX calls for each one.</p>
  
  <pre><code>for (var i = 0; i &lt; linkList.length; i++)
  {
      $.ajax({
          url: linkList[i].getAttribute("href"),
          cache: false
      }).done(function( html )
      {
          var hasAppended = false;
          if (html.indexOf('someStringOnGottenPage') != -1 &amp;&amp; !hasAppended)
          {
              hasAppended = true;
              var id = linkList[i].getAttribute("href").substring(linkList[i].getAttribute("href").indexOf('='));
              $( "#links a[href*='" + id + "']" ).append(' THIS PAGE CONTAINS SPECIFIED DATA');
          }
      });
  }
  </code></pre>
  
  <p>To try to put it simply, I have a page with a list of links. I wish to iterate through the links and get AJAX to process the contents of each of the links pages, and report back if that page contains something specified.</p>
  
  <p>The issue I'm having is the value of [i] used to iterate through the linkList is always 6, and it should never be. I'm assuming I need to pass some data so that when .done finally triggers, it knows its [i] value from when AJAX first triggered and not the value of [i] when .done triggers later.</p>
  
  <p>How do I go about ensuring .done knows it's [i] value when AJAX is first called?</p>