Jquery jsonp response error - Callback was not called

前端 未结 3 840
难免孤独
难免孤独 2021-02-09 07:34

I\'m trying to get some information from a different domain, the domain allows only jsonp call - others get rejected. How can I get the content instead of execution? Because I g

3条回答
  •  無奈伤痛
    2021-02-09 07:50

    var url = "https://status.github.com/api/status.json?callback=apiStatus";
    $.ajax({
        url: url,
        dataType: 'jsonp',
        jsonpCallback: 'apiStatus',
        success: function (response) {
            console.log('callback success: ', response);
        },
        error: function (xhr, status, error) {
            console.log(status + '; ' + error);
        }
    });
    

    Try this code.

    Also try calling this url directly in ur browser and see what it exactly returns, by this way You can understand better what actually happens :).

提交回复
热议问题