【问题标题】:Here map REST api jquery return error这里map REST api jquery返回错误
【发布时间】: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


【解决方案1】:

请求的 URL 应该是这样的

https://traffic.cit.api.here.com/traffic/6.0/incidents.json?app_id=APP_ID&app_code=APP_CODE

在你的情况下:

https://traffic.cit.api.here.com/traffic/6.0/incidents.json?app_id=DemoAppId01082013GAL&app_code=AJKnXv84fjrb0KIHawS0Tg

注意:永远不要透露您的应用 ID 和应用代码。

【讨论】:

  • tq 为了快速响应,我仍然收到错误.. 即使我将 app_id 和 app_code 放到了 url 中。 jquery 仍然抛出错误。
  • 感谢@Jitendra Meena。我使用 90 天免费试用应用程序 ID 根据您的建议更改了应用程序 ID 和应用程序代码。然后它解决了未知错误
猜你喜欢
  • 2020-12-09
  • 2020-11-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-08-30
  • 2015-02-19
相关资源
最近更新 更多