passing array into $.getJSON callback function
<p>I have developed following code. </p>

<pre><code> for (var x = 0; x &lt; address.length; x++) {  

    //infoWindowContent[x]  = "&lt;strong&gt;Address&lt;/strong&gt;&lt;br&gt;" + address[x];



         $.getJSON('http://maps.googleapis.com/maps/api/geocode/json?address='+address[x]+'&amp;sensor=false&amp;',null,function (data) {
            var p = data.results[0].geometry.location;

  var latlng = new google.maps.LatLng(p.lat, p.lng);
    //  resultsMap.setCenter(latlng);  
    alert(address[x]);
});
}  
</code></pre>

<p>What I need to do is get each address value. When executing this code it says undefined. That is because alert(address[x]) is inside $.getJson method. How can I pass address array into this block. I know it use to send data to server. But is there any method to get address values inside function?</p>