geoplugin에서 위치를 가져 오는 작은 스크립트가 있습니다 ... 전역으로 선언 한 변수에 반환 된 좌표를 저장하고 싶습니다. 그러나 어떤 이유로 콜백을 읽지 않습니다. 그것. 글로벌 변수를 콜백으로 사용하려면 어떻게해야합니까?jquery callback 전역 변수를 사용하지 않음
if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
myLocation = new google.maps.LatLng(position.coords.latitude,position.coords.longitude);
}, function() {
noLocation();
},{timeout: 20});
}
else if (google.gears) {
var geo = google.gears.factory.create('beta.geolocation');
geo.getCurrentPosition(function(position) {
myLocation = new google.maps.LatLng(position.latitude,position.longitude);
}, function() {
noLocation();
});
}
else {
noLocation();
}
function noLocation() {
$.getJSON("http://www.geoplugin.net/json.gp?id=117.201.92.17&jsoncallback=?",
function(data) {
if (data != "" && data.geoplugin_latitude != "")
myLocation = new google.maps.LatLng(data.geoplugin_latitude, data.geoplugin_longitude)
else
myLocation = new google.maps.LatLng()
});
} 내가 때문에 비동기 호출의의를 생각하는 몇 가지 이유 ... 내가 몇 가지 방법 문제를 극복 할 수 들어
?
얘기하고 무엇을 당신이 "그것을 읽지 않습니다"에 의해 의미합니까 어떤 변수? – casablanca