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
file 的一部分。我也认为,有问题$.ajaxSetup
$.ajaxSetup({
error: function() {
layout.message("error", "Oopss!!!, Something went wrong. please refresh your browser or try again.");
gq._gaqPush(["_trackEvent", "Error", "Oopss!!!, 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(":"), 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["1"]), gq.settings.surah = verse.surah, gq.settings.ayah = verse.ayah), gq.player.reset(),
!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, function(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", "Oopss!!!, Something went wrong. please refresh your browser or try again.");
gq._gaqPush(["_trackEvent", "Error", "Oopss!!!, 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)
解决方案
是设置ajax请求的默认值,所以调用错误处理程序/回调的原因是因为你的ajax调用抛出异常,我建议你在浏览器开发工具中检查网络调试,看看有什么问题。
推荐阅读
- google-cloud-platform - Google Cloud Run 如何处理异步调用?
- python - 如何使用 Python 按列对不同的 csv 文件进行排序并将它们合并为一个?
- javascript - 在 2 个 div 的碰撞中,使用 Javascript 在其中一个中添加一个类
- r - R:将日期从每天转换为每周并绘制它们
- javascript - 如何在 Firebase 存储参考中使用变量
- c - 初始化一个包含 20 个元素的数组以稍后更新值,但数组的某些元素在 C 中以非零开头?这是为什么?
- python - 删除数据集中字符串的结尾(python)
- javascript - 如何挂载像 codepen 这样的 Vue 3 CLI 项目
- c# - 试图获得骰子卷的随机数
- php - 带有 MySQL 驱动程序的 Laravel 8 原子锁根据 Web 浏览器执行不同的操作