【发布时间】:2013-12-27 13:05:56
【问题描述】:
我现在在 phonegap android 应用程序中工作,我需要用户的当前地址,所以我使用了这个 JSON api。
这是我从 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
谁能告诉我问题出在哪里?
【问题讨论】:
标签: javascript android json cordova jsonp