我正在工作,現在在phonegap android應用程序中,我需要用戶的當前地址,以便我使用此 JSON api。從javascript中獲取位置從JSON
這是我的代碼從JSON API
$.ajax('http://maps.googleapis.com/maps/api/geocode/json?latlng=26.9008773,75.7403539&sensor=true', {
dataType: 'jsonp',
timeout: 3000,
data: {
_method: 'GET'
},
success: function (data,status) {
if (data._status != 200) {
console.log('received error', data._status);
// handle error
}else{
console.log('received data', data);
// do something useful with the data
}
},
error: function(data,status) {
var myObject = JSON.stringify(data);
console.log("Data Returned is " + myObject);
console.log("Status is " + status);
alert('error');
},
complete: function(data, status) {
alert('complete');
}
});
獲取位置更新數據那張錯誤區間的每一次,那麼完整的部分,從來沒有進入成功的一部分。 控制檯輸出爲:
12-10 11:11:34.393: I/Web Console(10620): Data Returned is {"readyState":4,"status":404,"statusText":"error"} at file:///android_asset/www/index.html:263
12-10 11:11:34.393: I/Web Console(10620): Status is error at file:///android_asset/www/index.html:264
誰能告訴我,究竟哪裏的問題是什麼?
謝謝,我有加<訪問起源=「*」 />到配置文件,但還是同樣的結果... – Rohit