how to 'bake' parameters into click() call jquery?
<p>I've got an ajax call that collects XML, and based on that data creates a number of divs on which I attach click() jquery listeners.  When clicked, I want those divs to call a function and to pass a parameter into that function.  However, by the time the click is called the value of the parameter has changed.  Here's an example from a <a href="http://jsfiddle.net/snTEf/1/" rel="nofollow">jsfiddle I built</a> to demonstrate the problem:</p>

<pre><code>    $(document).ready(function() {

    function x() {

      $.ajax({
        type: "POST",
        url: "/echo/xml/",
        dataType: "xml",
        data: {
            xml: "&lt;the&gt;xml&lt;/the&gt;"
        },
        success: function(xml) { 
          console.log('success');                

          $('#test').show(); 

          var text = "CORRECT";      

          $('#test').click(function() {

            insertText(text);
            console.log(text);
          });

          text = "WRONG";

        }        
      });
    }

    x();

  });

  function insertText(t) {

      $('#test').html(t);
  }
</code></pre>

<p>I want the text to show up as CORRECT, not WRONG.</p>

<p>​I know this is a bit of a convoluted example but I'm trying to simulate my actual code as much as possible in terms of scope and what is going on.  By the time the <code>click()</code> function gets called based on a click, the value of <code>text</code> has changed.  Is there some way to 'bake' the value of <code>text</code> into the <code>click()</code> call at the time I create it?  I'll be creating a number of these through a <code>for</code> loop as it runs through the XML and don't want to hang on to all that data into variables for use later.</p>
