title: AJAX callback function intermittently fails to add GET parameter
body: <p>I have a <code>&lt;ul&gt;</code> with each <code>&lt;li&gt;</code> having an id like <code>&lt;li id='entry24'&gt;</code>.  When one is clicked, I need to query the server for that entries information, by sending a get request to <code>/query/getEntry/id=24</code>.</p>
  
  <p>Using this code:</p>
  
  <pre><code>for(var entry = 0; entry &lt; entryIds.length; entry++) {
      $("#entry" + entryIds[entry]).click(function() {
          $.get(
              "/query/getEntry",
              {id: entryIds[entry]},
              getEntryCallback,
              "html"
          )
      });
  }
  </code></pre>
  
  <p>I found that every request was sending the same id - the id of the last entry.  After some research, I modified my code to this:</p>
  
  <pre><code>for(var entry = 0; entry &lt; entryIds.length; entry++) {
      var entryId = entryIds[entry];
      $("#entry" + entryId).click(function(event) {
          $.get(
              "/query/getEntry",
              {id: event.target.id.replace("entry", "")},
              getEntryCallback,
              "html"
          )
      });
  }
  </code></pre>
  
  <p>which works better (each <code>&lt;li&gt;</code> sends the correct id).  However, looking at the Firebug console I can see requests being made with each click, but about 75% of the time they show <code>/query/getEntry/id=</code> in red.. meaning the id wasn't actually sent and I didn't get the results I was expecting.</p>
  
  <p>I can confirm that every <code>&lt;li&gt;</code> DOES have an appropriate <code>id</code> field.</p>
  
  <p>Any help/advice MUCH appreciated!</p>