API 接口 https://lbs.amap.com/api/webservice/guide/api/georegeo
返回数据
{"status":"1","info":"OK","infocode":"10000","count":"1","geocodes":[{"formatted_address":"北京市朝阳区阜通东大街 6 号","country":"中国","province":"北京市","citycode":"010","city":"北京市","district":"朝阳区","township":[],"neighborhood":{"name":[],"type":[]},"building":{"name":[],"type":[]},"adcode":"110105","street":"阜通东大街","number":"6 号","location":"116.482086,39.990496","level":"门牌号"}]}
比如我的 callback=getGPS
$.get('url', getGPS) ???
刚学到回调函数这,回调函数就是写好一个函数,当作参数传给另一个函数调用,那这个 callback 在这个 api 中有什么意义?应该怎么使用?
我现在直接
var results = $.get(url, getGeocodes);
function getGeocodes() {
var tude = results.responseJSON.geocodes[0].location;
$("#id_detect_coordinate").val(tude);
}
}
我没有填那个 callback,直接拿到返回数据, 所以那个 callback 到底有什么用?正确使用方法是什么?