function foreignCoordinatesArray(){
var coordinates = [];
$.getJSON('/critics.json?travel_id=' + $('#foreign_travel').val(), success);
function success(ary) {
for(var a in ary){
var obj = ary[a];
coordinates.push(new google.maps.LatLng(obj.latitude, obj.longitude));
}
}
console.log(coordinates);
}
最后坐标仍然是 [] 而不是 [{...},{...},...]。我想这一定是闭包的问题
如何在坐标数组中获得我想要的值?