【发布时间】:2014-05-17 21:41:26
【问题描述】:
我有以下内容,但标题只是重复相同。我怎样才能在getJSON 函数中使用title?
for (var x = 0; x < temp_addresses.length; x++) {
var title = temp_addresses[x].title;
var jqxhr = $.getJSON('http://maps.googleapis.com/maps/api/geocode/json?address='+temp_addresses[x].gps+'&sensor=false', null, function(data) {
var p = data.results[0].geometry.location
latlng = new google.maps.LatLng(p.lat, p.lng);
console.log(title+' - '+latlng);
});
}
【问题讨论】:
-
@CrescentFresh 这不包括我的 Q
-
我怀疑确实如此,以迂回的方式。您目前如何无法获取
title变量? -
这实际上是与stackoverflow.com/q/19701823/218196 更接近的副本(与
[jquery] ajax loop variable一起找到),但另一个对IMO 有更好的解释。
标签: javascript jquery ajax json getjson