【发布时间】:2017-03-22 10:36:58
【问题描述】:
我正在测试 Here Maps REST api,但出现错误。当我尝试使用此处的地图 REST api 来模拟数据请求以获取交通信息时。以下是我的代码:
<script>
$(document).ready(function(){
$("button").click(function(){
console.log("test 1");
$.ajax({
url: 'https://traffic.cit.api.here.com/traffic/6.0/incidents.json',
type: 'GET',
dataType: 'jsonp',
jsonp: 'jsoncallback',
data: {
bbox: '52.5311,13.3644;52.5114,13.4035',
criticality: 'minor',
app_id: 'DemoAppId01082013GAL',
app_code: 'AJKnXv84fjrb0KIHawS0Tg'
},
success: function (data) {
alert(JSON.stringify(data));
},
error: function (data, errorThrown) {
console.log("error " + errorThrown);
alert("error "+ errorThrown);
}
});
});
});
</script>
tq 提前
注意在运行代码时添加错误捕获: enter image description here
【问题讨论】:
-
哪个错误?在哪里?
-
错误是什么? :D
-
jsfiddle.net/33bwfg8w 我没有改变任何东西。您的代码正在运行 :)
-
谢谢 cbalakus,我在你的 jsfiddle 代码中尝试了它,但它没有像 Here map 示例中那样返回 json 数据。我从这个链接得到这个代码:developer.here.com/api-explorer/rest/traffic/traffic-incidents。并尝试将其集成到我自己的应用程序中。但我无法获得应有的 json 数据。
标签: javascript jquery rest