I have a getJSON request. This request is working fine, but i can't store the output data in array.
Here is the current code:
var loc = [];
jQuery.getJSON('http://maps.googleapis.com/maps/api/geocode/json?address=Los Angeles, CA 90012&sensor=false', null, function (data) {
var p = data.results[0].geometry.location
var latlng = (p.lat, p.lng);
loc.push(latlng);
});
console.log('Final: '+loc);
The console is showing this: 'Final: ', so the loc.push(latlng)
isn't working.
How can I store getJSON datas in the outside array?