我有geoCode函数,它使用回调函数在异步请求完成后执行某些操作。但是,它返回NULL值。
function codeAddress(callback) {
/***** build string address from form data
var address = addressOne + "," + addressTwo + "," + region + "," + zip + "," + country;
*****/
var geocodeAddress = geocoder.geocode( { 'address': address}, function (results, status) { callback( results ) } );
}
codeAddress(function(returnData){
console.log("results= " + returnData);
console.log(returnData);
});
这给出了空数组
答案 0 :(得分:0)
var returnData = function () {
return data;
};
codeAddress (returnData ());
应该能够通过你喜欢的。