为什么这不起作用?如何改进它以使其有效?
...
showCurrent(passLatLon); // first call, coordinates unresolved
var param={
lat:selectLat,
lon:selectLon,
};
function getResults(param, function(data){
alert(JSON.stringify(data)); // still unresolved
}
// somewhere around here geolocation service kicks in and passes
// coordinates to `passLatLon` function
// if you try to look at selectLat/selectLon at this point of executin,
// they will contain values from previous probe
答案 0 :(得分:0)
使用while (1 == 1)
会导致阻塞语句,并且不会执行其他代码。尝试替换
while (1 == 1) {
window.setTimeout(moveCharacter, 400);}
window.setInterval(moveCharacter, 400);