title: jQuery anonymous function variable scope
body: <p>Can someone please explain why the following <strike>doesn't work</strike> works:</p>
  
  <pre><code>function displayResults(data) {
      $("#odNextPage").click(function() {
          alert(data.queryType); // "undefined"
          return false;
      });
  }
  </code></pre>
  
  <p>Why can I use the data object inside the click anonymous function?</p>
  
  <p><strong>Edit</strong>: The queryType property wasn't actually set which I think caused the problem, sorry. I'd still be interested for someone to explain why it now <em>does</em> work, given that the click function is executed outside the scope of the data object.</p>