javascript - How to increase variable scope -
my coffeescript looks this:
initialize = -> $.ajax url: "map_groups/1.json" type: "get" datatype: "json" success: (response) -> console.log response mapoptions = center: new google.maps.latlng(response.latitude, response.longitude) zoom: 16 maptypeid: google.maps.maptypeid.roadmap the problem is, mapoptions needs able access ajax response. how can increase scope of response can accessed mapoptions?
in ajax
for success function, can have this,
success:function(response) { callfunction(response); } your callfunction should return response, can call function use in mapoptions like
mapoptions = center: new google.maps.latlng(response.latitude, response.longitude) zoom: 16 maptypeid: google.maps.maptypeid.roadmap, something:callfunction // ajax response
Comments
Post a Comment