function test(){
var distance=null;
first();
second();
third();
alert(distance);//it shows null always because it take 2 second to complete.
}
function first(tolat, tolon, fromlat,fromlon){
// calulating road distance between two points on the map using any other distance caluculating apis.
distance=dis; // update the value of distance but it takes 2 second to complete.
}
function second(){}
function third(){}
我在代码中遇到了这种情况,现在函数三在第一和第二个函数完成执行之前被多次调用,并且距离值没有更新。