title: Get variable from callback function
body: <pre><code>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);
  }
  </code></pre>
  
  <p>At the end coordinates will still be [] and not [{...},{...},...].
  I guess this must be a problem with closures</p>
  
  <p>How can I have my desired value in coordinates array?</p>