微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

为什么执行这部分javascript代码?

如何解决为什么执行这部分javascript代码?

从我的 index.PHP 文件中, 执行此行时:

<script src="javascript/GlobalQuran.js"></script>

那么, GlobalQuran.js 文件已加载。 当加载那个 js 文件时,输出总是显示

"Oopss!!!,Something went wrong. please refresh your browser or try again."

我认为此错误消息是由以下代码产生的,该代码GlobalQuran.js 文件的一部分。我也认为,$.ajaxSetup

有问题
$.ajaxSetup({
    error: function() {
        layout.message("error","Oopss!!!,Something went wrong. please refresh your browser or try again.");
        gq._gaqPush(["_trackEvent","Error",Something went wrong."])
    }
});

谁能告诉我为什么要执行这部分 js 代码?我是 JavaScript 的新手

GlobalQuran.js 文件代码的某些部分:

.
.
.
notCachedQuranID ? ($jsonp = $.support.cors ? "" : ".jsonp?callback=?",$.ajaxSetup({
            cache: !0,jsonpCallback: "quranData"
        }),$.getJSON(c + $jsonp,function(a) {
            gq._loadResponse(a,firstLoad)
        })) : (gq.layout.display(!0),gq.player.load("play"));
        return !1
    },_loadResponse: function(a,b) {
        if ("object" == typeof a) gq.data = $.extend(!0,gq.data,a),gq.data.loaded = !0;
        if (gq.search.isActive() && (gq.search.init(),gq.search.loading(!1),0 < gq.search.totalRows()))
            for (var c in a.search.quran) {
                gq.search._positionStartVerse = c;
                break
            }
        if (a.languageSelected) gq.settings.selectedLanguage = a.languageSelected;
        b ? (gq.player.init(),!gq.quran.length() && "object" == typeof a && a.quran && ($.each(a.quran,function(a) {
            gq.quran.add(a)
        }),this.url.save()),gq.layout.displayStartup("object" ==
            typeof a)) : (gq.layout.display("object" == typeof a),gq.player.load("play"))
    },url: {
        load: function() {
            var a = window.location.hash,a = a.split("/"),b = a.length;
            if (2 < b && "search" == a["1"]) {
                if (gq.search.keyword() == a["2"] && 0 == gq.search.position()) return !1;
                gq.search._keyword = a["2"];
                gq.search._position = 0;
                return !0
            }
            if (2 < b && gq.settings.page != a["2"]) return gq.quran.reset(),selectedBy = a["1"].split("|"),$.each(selectedBy,function(a,b) {
                gq.quran.add(b)
            }),verse = a["2"].split(":"),1 < verse.length ? (gq.settings.surah = Quran._fixSurahNum(parseInt(verse["0"])),gq.settings.ayah = Quran._fixAyahNum(gq.settings.surah,parseInt(verse["1"]))) : (verse = Quran.ayah.fromPage(a["2"]),gq.settings.surah = verse.surah,gq.settings.ayah = verse.ayah),gq.player.reset(),!0;
            return /^[0-9]+:?[0-9]*$/.test(a["1"]) ? (verse = a["1"].split(":"),parseInt(verse["1"]))) : (verse = Quran.ayah.fromPage(a["1"]),!0) : !1
        },save: function() {
            window.location.hash = "#!" + this.page()
        },hashless: function() {
            var a = window.location.href,b = a.indexOf(window.location.hash) || a.length;
            return a.substr(0,b)
        },page: function(a) {
            if (gq.search.isActive()) return "/search/" + gq.search.keyword();
            url = "/";
            (by = gq.quran.selectedString()) && (url += by + "/");
            return url += a || gq.settings.page
        },ayah: function(a,b) {
            if (gq.search.isActive()) return "/" + gq.settings.surah + ":" + gq.settings.ayah;
            url = "/";
            (by = gq.quran.selectedString()) && (url += by + "/");
            return url = a ? url +
                (gq.settings.surah + ":" + gq.settings.ayah) : url + (a + ":" + b)
        }
    },_cookieRead: function() {
        for (var a = "",b = document.cookie.split(";"),c = 0; c < b.length; c++) {
            for (var d = b[c];
                " " == d.charat(0);) d = d.substring(1,d.length);
            0 == d.indexOf("settings=") && (a = d.substring(9,d.length))
        }
        a = $.parseJSON(a);
        $.extend(!0,this.settings,a);
        this.quran.init();
        this.recitor.init()
    },_cookieSave: function(a) {
        var b = "undefined" == typeof a,c = "",a = b ? this.settings : a;
        if (!b && null == a) return "{}";
        $.each(a,b) {
            c = "object" == typeof b || "array" == typeof b ?
                c + ('"' + a + '":' + gq._cookieSave(b) + ",") : "string" != typeof b ? c + ('"' + a + '":' + b + ",") : c + ('"' + a + '":"' + b + '",')
        });
        c = c.slice(0,-1);
        c = "{" + c + "}";
        if (b) a = new Date,a.setTime(a.getTime() + 31536E6),a = "; expires=" + a.toGMTString(),document.cookie = "settings=" + c + a + "; path=/";
        return c
    },googleAnalytics: function() {
        var a = document.createElement("script");
        a.type = "text/javascript";
        a.async = !0;
        a.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js";
        var b = document.getElementsByTagName("script")[0];
        b.parentNode.insertBefore(a,b);
        "undefined" == typeof _gaq && (_gaq = []);
        window._gaq = _gaq || [];
        this.googleAnalyticsID && _gaq.push(["b._setAccount",this.googleAnalyticsID]);
        _gaq.push(["_setAccount",this._gaID]);
        this._gaqPush(["_setSessionCookieTimeout",36E7]);
        this._gaqPush(["_trackPageview"])
    },_gaqPush: function(a) {
        _gaq.push(a);
        this.googleAnalyticsID && (a[0] = "b." + a[0],_gaq.push(a))
    }
};
.
.
.
jQuery.fn.extend({
    scrollTo: function(a,b,c) {
        b = b || 0;
        return this.each(function() {
            var d = $(this).offset().top + b;
            $("html,body").animate({
                scrollTop: d
            },a,c)
        })
    }
});
$.ajaxSetup({
    error: function() {
        layout.message("error",Something went wrong."])
    }
});

开发者控制台错误

Mixed Content: The page at 'https://www.muslimpoint.org/word-by-word-quran/' was loaded over HTTPS,but requested an insecure frame 'http://www.facebook.com/plugins/like.PHP?href=http%3A%2F%2Fwww.facebook.com%2Fpages%2FQuran-GlobalQurancom%2F192781430775518&layout=button&show_faces=false&width=50&action=like&colorscheme=light&height=24'. This request has been blocked; the content must be served over HTTPS.
jqueryWithTools.pack.js:154 Mixed Content: The page at 'https://www.muslimpoint.org/word-by-word-quran/' was loaded over HTTPS,but requested an insecure XMLHttpRequest endpoint 'http://api.globalquran.com/all/page/1'. This request has been blocked; the content must be served over HTTPS.
send @ jqueryWithTools.pack.js:154
(index):1 Mixed Content: The page at 'https://www.muslimpoint.org/word-by-word-quran/' was loaded over HTTPS,but requested an insecure script 'http://s7.addthis.com/js/250/addthis_widget.js'. This request has been blocked; the content must be served over HTTPS.
apis.google.com/se/0/_/+1/fastbutton?usegapi=1&size=tall&annotation=none&origin=https%3A%2F%2Fwww.muslimpoint.org&url=https%3A%2F%2Fwww.muslimpoint.org%2Fword-by-word-quran%2F&gsrc=3p&jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.en_US.bSaSBnJo3mU.O%2Fam%3DAQ%2Fd%3D1%2Fct%3Dzgms%2Frs%3DAGLTcCOlScUDCc6laSimwcYo4nXUQAS-sQ%2Fm%3D__features__#_methods=onPlusOne%2C_ready%2C_close%2C_open%2C_resizeMe%2C_renderstart%2Concircled%2Cdrefresh%2Cerefresh%2Conload&id=I0_1620128639790&_gfid=I0_1620128639790&parent=https%3A%2F%2Fwww.muslimpoint.org&pfname=&rpctoken=64765965:1 Failed to load resource: the server responded with a status of 404 ()
apis.google.com/se/0/_/+1/fastbutton?usegapi=1&size=tall&annotation=none&origin=https%3A%2F%2Fwww.muslimpoint.org&url=https%3A%2F%2Fwww.muslimpoint.org%2Fword-by-word-quran%2F&gsrc=3p&jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.en_US.bSaSBnJo3mU.O%2Fam%3DAQ%2Fd%3D1%2Fct%3Dzgms%2Frs%3DAGLTcCOlScUDCc6laSimwcYo4nXUQAS-sQ%2Fm%3D__features__#_methods=onPlusOne%2C_ready%2C_close%2C_open%2C_resizeMe%2C_renderstart%2Concircled%2Cdrefresh%2Cerefresh%2Conload&id=I0_1620128639790&_gfid=I0_1620128639790&parent=https%3A%2F%2Fwww.muslimpoint.org&pfname=&rpctoken=64765965:1 Failed to load resource: the server responded with a status of 404 ()
apis.google.com/se/0/_/+1/fastbutton?usegapi=1&annotation=none&origin=https%3A%2F%2Fwww.muslimpoint.org&url=http%3A%2F%2Fglobalquran.com%2F&gsrc=3p&jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.en_US.bSaSBnJo3mU.O%2Fam%3DAQ%2Fd%3D1%2Fct%3Dzgms%2Frs%3DAGLTcCOlScUDCc6laSimwcYo4nXUQAS-sQ%2Fm%3D__features__#_methods=onPlusOne%2C_ready%2C_close%2C_open%2C_resizeMe%2C_renderstart%2Concircled%2Cdrefresh%2Cerefresh%2Conload&id=I1_1620128639801&_gfid=I1_1620128639801&parent=https%3A%2F%2Fwww.muslimpoint.org&pfname=&rpctoken=24294907:1 Failed to load resource: the server responded with a status of 404 ()
apis.google.com/se/0/_/+1/fastbutton?usegapi=1&annotation=none&origin=https%3A%2F%2Fwww.muslimpoint.org&url=http%3A%2F%2Fglobalquran.com%2F&gsrc=3p&jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.en_US.bSaSBnJo3mU.O%2Fam%3DAQ%2Fd%3D1%2Fct%3Dzgms%2Frs%3DAGLTcCOlScUDCc6laSimwcYo4nXUQAS-sQ%2Fm%3D__features__#_methods=onPlusOne%2C_ready%2C_close%2C_open%2C_resizeMe%2C_renderstart%2Concircled%2Cdrefresh%2Cerefresh%2Conload&id=I1_1620128639801&_gfid=I1_1620128639801&parent=https%3A%2F%2Fwww.muslimpoint.org&pfname=&rpctoken=24294907:1 Failed to load resource: the server responded with a status of 404 ()
(index):1 Mixed Content: The page at 'https://www.muslimpoint.org/word-by-word-quran/' was loaded over HTTPS,but requested an insecure favicon 'http://globalquran.com/favicon.ico'. This request has been blocked; the content must be served over HTTPS.
2GlobalQuran.js:3551 Uncaught TypeError: this.fullScreen is not a function
    at d (GlobalQuran.js:3551)
    at GlobalQuran.js:3607
    at handle (jqueryWithTools.pack.js:64)
    at q (jqueryWithTools.pack.js:58)

解决方法

根据 ajaxSetup 的 jquery 文档

是为ajax请求设置默认值,所以调用错误处理程序/回调的原因是因为你的ajax调用抛出异常,建议你在浏览器开发工具中检查网络调试,看看有什么问题.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。