"未捕获的语法错误:意外令牌:"尝试从 instagram/user_name/media 获取数据时



我正试图从https://www.instagram.com/user_name/media/

这是我的代码:

$.ajax({
    type:     "GET",
    url:      "https://www.instagram.com/justinbieber/media?callback=?",
    dataType: "jsonp",
    success: function(data){
        console.log(data);
    }
   });

因此,我有"未捕获的SyntaxError:意外的令牌:"当我试图获取json时,我遇到了下一个错误:

XMLHttpRequest无法加载https://www.instagram.com/justinbieber/media.请求的资源上不存在"Access Control Allow Origin"标头。因此,不允许访问源"null"。

这个错误在本地主机和github.io上都重复出现。我应该提到,使用后端是不允许的

提前感谢

固定

jQuery.ajax = function (d) {
    var b = location.protocol,
    e = RegExp(b + "//" + location.hostname),
    f = "http" + (/^https/.test(b) ? "s" : "") + "://query.yahooapis.com/v1/public/yql?callback=?";
    return function (a) {
        var c = a.url;
        if (/get/i.test(a.type) && !/json/i.test(a.dataType) && !e.test(c) && /:///.test(c)) {
            a.url = f;
            a.dataType = "json";
            a.data = {
                q: 'select * from html where url="{URL}" and xpath="*"'.replace("{URL}", c + (a.data ? (/?/.test(c) ? "&" : "?") + jQuery.param(a.data) : "")),
                format: "xml"
            };
            !a.success && a.complete && (a.success = a.complete, delete a.complete);
            var b = a.success;
            a.success = function (a) {
                b && b.call(this, {
                    responseText: (a.results[0] || "").replace(/<script[^>]+?/>|<script(.|s)*?/script>/gi, "")
                }, "success")
            }
        }
        return d.apply(this, arguments)
    }
}(jQuery.ajax);

最新更新