How to access a closure variable from within a callback
<p>I am looping through an array of urls. Each one fetches some jsonp data from a different domain. The success handler needs to be able to access the data in the original loop, however when called from the callback it is always the last value and not the value that was set when the ajax function was called. How do I access or pass this value to the callback?</p>

<pre><code>for(var site in data.sites){
    var domain =  data.sites[site].domain;
    $('#site-logout').append('&lt;div class="processing" id="' + domain.replace(".","-") + '"&gt;&lt;strong&gt;' + domain + '&lt;/strong&gt; is logging out.');
    $.getJSON(url, function(data){
        if(data.success == true)
            $("#" +  domain.replace(".","-")).removeClass("processing").addClass("processed").html('&lt;strong&gt;' + domain + '&lt;/strong&gt; has logged out.');
        else
            $("#" +  site.domain.replace(".","-")).removeClass("processing").addClass("error").text('&lt;strong&gt;&lt;a href="http://' + domain + '"&gt;' + domain + '&lt;/a&gt;&lt;/strong&gt; has failed to log out. Follow the link to try manually.');
    });
}
</code></pre>
