所以我有这样的功能 -
IPGeocoding = (data) ->
coords = []
_.each(data, (datum) ->
$.ajax(
url: "http://freegeoip.net/json/#{datum}"
type: 'GET'
async: false
success: (result) ->
lat = result.latitude
lon = result.longitude
pair = [lat, lon]
coords.push(pair)
console.log coords
)
return coords
)
我希望仅在所有请求都返回时才返回坐标。我怎么做?