In the below code when I stop the code in FireBug, the "results" object is a nice array filled with good geocoded values.
However, the locations[] array I put it into is full of all "undefined" values.
Shouldn't that be impossible because I can see the results[0] each time working nicely?
var locations = [];
function makeCallback(addressIndex) {
var geocodeCallBack = function (results, status) {
if (status == "success") {
locations[addressIndex] = results[0];
}
};
return geocodeCallBack;
}
$(function() {
for (var x = 0; x < addresses.length; x++) {
$.getJSON('http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=' + addresses[x], null, makeCallback(x));
}
});