0

I have developed following code.

 for (var x = 0; x < address.length; x++) {  

    //infoWindowContent[x]  = "<strong>Address</strong><br>" + address[x];



         $.getJSON('http://maps.googleapis.com/maps/api/geocode/json?address='+address[x]+'&sensor=false&',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]);
});
}  

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?

bob
  • 4,282
  • 2
  • 22
  • 30
Ming han
  • 17
  • 4

0 Answers0