【发布时间】:2017-06-21 14:17:48
【问题描述】:
var url = "https://dev.virtualearth.net/REST/v1/Locations?query="
+ encodeURIComponent('Oakleaf Dr Meadow Valley CA 95956 United States')
+ "&incl=queryParse"
+ "&output=json"
+ "&key=" + key
$.ajax({
url:url,
type:"GET",
dataType:"jason",
success: function(data){
lat=data.resourceSets[0].resources[0].point.coordinates[0];
},
error: function(r){ console.log(r)}
});
好的,我搜索了答案,必须使用jsonp。
$.ajax({
url: url,
type: "GET",
dataType: 'jsonp',
jsonp: "jsonp",
success: function(data) {
var lat=data.resourceSets[0].resources[0].point.coordinates[0],
lng=data.resourceSets[0].resources[0].point.coordinates[1];
console.log(lat);
},
error: function(response) {
console.log(JSON.stringify(response));
}
});
然后,我得到“Uncaught SyntaxError: Unexpected token :” 我发现最多的答案是对服务器端脚本进行更改,这在这种情况下不适用。现在呢?
【问题讨论】:
-
语法错误是错误函数抛出的吗?错误:函数(响应){ console.log(JSON.stringify(响应)); } 或在请求期间
标签: json rest dictionary bing-maps bing