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

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

debian - 500 Error upon login into Plesk Admin - auth.php3? -