javascript - jQuery ajax jsonp 意外标记 :

标签 javascript jquery ajax

我正在尝试从第三方获取数据 http://api.bing.net/json.aspx?Appid=APPID&query=SEARCH_TERM&sources=Web&web.count=40&web.offset=41

所以我只是使用jsonp来获取数据。我得到了200状态代码。但是我没有得到成功的结果数据。我也尝试了回调它不起作用。

附上我的源代码:

    $.ajax({
      type : "GET",
      url : "http://api.bing.net/json.aspx?Appid=APPID&query=SEARCH_TERM&sources=Web&web.count=40&web.offset=41",
      dataType : "jsonp",
      success : function(data){
          console.log(data);
      },
      error : function(error) {
          console.log(error);
      }
    });

控制台返回错误:

Uncaught SyntaxError: Unexpected token :

如何解决这个问题...

最佳答案

您的回复似乎有效,请尝试此操作

$.ajax({
          type : "GET",
          url : "http://api.bing.net/json.aspx?Appid=APPID&query=SEARCH_TERM&sources=Web&web.count=40&web.offset=41",
          dataType : "json",
          success : function(data){
              console.log(data);
          },
          error : function(error) {
              console.log(error);
          }
        });

关于javascript - jQuery ajax jsonp 意外标记 :,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22063528/

相关文章:

javascript - 将文本添加到纯数字文本字段以提高可用性?

javascript - 获取唯一的数据属性值并从中创建键值数组?

javascript - Javascript 窗口打印的设置

javascript - Jquery 附加来自 LaravelBalde 的内容

javascript - 仅使用 Chrome 绘制图像速度缓慢

javascript - 如何从 javascript 中的对话框 json 构建 CQ.Dialog?

javascript ajax : get value

javascript - 数组的数组 json Javascript,ajax 响应

javascript - 如果我得到结果,在 ajax 调用中隐藏 div

javascript - 在不重定向的情况下在 DIV 中加载页面