【问题标题】:JSONP error, Uncaught SyntaxErrorJSONP 错误,未捕获的 SyntaxError
【发布时间】:2018-05-04 11:44:33
【问题描述】:

我收到了 SyntaxError 但与其他链接一起工作正常。有什么想法???

function loadData() {
    var wikiUrl = 'http://www.masslottery.com/data/json/search/dailygames/history/15/201711.json';
    //http://www.masslottery.com/data/json/search/dailygames/history/15/201711.json?callback=jQuery1111019608043600812386_1511241988068&_=1511241988069
    $.ajax({
        url: wikiUrl,
        dataType: "jsonp",
    }).done(function (response) {
        for (var i = 0; i < response; i++) {
            console.log(response);
        }
    }).fail(function () {
        //  console.log(response);
    });
    return false;
};

$('#form-container').submit(loadData);

【问题讨论】:

  • 请发布控制台错误。
  • 那个 API 只是 JSON,不是 JSONP。

标签: javascript jquery json jsonp


【解决方案1】:
$.ajax({
   url:"your link"
   method: "get" or "post"
   dataType: "json" or "jsonp"
}).done(function(res) {
   console.log(res);
}).fail(function(error) {
   console.log(error);
});

你错过了方法。

【讨论】:

    猜你喜欢
    • 2014-05-27
    • 1970-01-01
    • 2016-12-21
    • 2015-08-19
    • 1970-01-01
    • 2013-04-16
    • 2017-04-16
    • 2015-11-06
    • 2022-10-30
    相关资源
    最近更新 更多