【发布时间】:2014-05-11 17:51:24
【问题描述】:
我想将来自 JSON 对象的值存储在全局变量中,以便稍后在我的代码中使用。显然这不起作用,即使它应该使 country 变量成为全局变量。
$.getJSON(reverseGeoRequestURL, function(reverseGeoResult){
window.country = reverseGeoResult.results[0].locations[0].adminArea1;
});
console.log(window.country);
【问题讨论】:
标签: javascript jquery variables scope global-variables