我无法理解这些错误:
" 阻止加载混合活动内容" http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
ReferenceError:jQuery未定义jQuery.noConflict();
ReferenceError:jQuery没有定义jQuery(' #like_box')。html(like_html);
"
如果有人遇到这样的问题,我可以看到问题出在哪里并修复它。 这是我正在使用的代码:
jQuery.noConflict();
var good_image_url = "images/good.png";
var bad_image_url = "images/bad.png";
function load_stats(url) {
jQuery.post("../../cgi-bin/test/like_new/wacko_like.pl", {
URL : this.location.href,
func: 'get_stats'
}, function(response){
setTimeout("finishAjaxLikeLoadStats('"+escape(response)+"')", 400);
});
}
function finishAjaxLikeLoadStats(response) {
response = unescape(response);
var the_vals = response.split(":");
jQuery("#like_count").html(the_vals[0]);
jQuery("#dislike_count").html(the_vals[1]);
}
function generate_like_html() {
var like_html = '<a href="javascript: void(0);" onclick="do_vote(document.location.href,1) "><img src="' + good_image_url +'" /></a>'
+ '<a href="javascript: void(0);" onclick="do_vote(document.location.href,2) "><img src="' + bad_image_url + '" /></a>'
+ '<span style="color: green">Likes: <span id="like_count">0</span></span>'
+ ' '
+ '<span style="color: red">Dislikes: <span id="dislike_count">0</span></span>';
jQuery('#like_box').html(like_html);
/* ok, now we have the stats - lets pre-update the numbers with real values :) */
load_stats(document.location.href);
}
function do_vote(LinkID,Type) {
jQuery.post("../../cgi-bin/test/like_new/wacko_like.pl", {
URL : this.location.href,
do_what: Type
}, function(response){
setTimeout("finishAjaxLike('"+escape(response)+"')", 400);
});
}
function finishAjaxLike(response) {
response = unescape(response);
var the_vals = response.split(":");
if (the_vals[0] == "1") {
alert("Sorry, you can't vote (can't see your IP!)");
}
if (the_vals[0] == "2") {
alert("Your vote has been counted, thanks!");
}
if (the_vals[0] == "3") {
alert("Your vote has been updated accordingly");
}
jQuery("#like_count").html(the_vals[1]);
jQuery("#dislike_count").html(the_vals[2]);
}
这是html:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-type" content="application/xhtml+xml; charset=utf-8" />
<meta http-equiv="Content-language" content="en-gb" />
<title>Like - Dislike</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="i_like.js"></script>
</head>
<body>
<p>Testing Like/Dislike Feature 1</p>
<div id="like_box"></div>
<script>
generate_like_html();
</script>
<!--
<a href="javascript: void(0);" onclick="do_vote(<%ID%>,1) "><img src="<%config.build_static_url%>/good.png" /></a>
<a href="javascript: void(0);" onclick="do_vote(<%ID%>,2) "><img src="<%config.build_static_url%>/bad.png" /></a>
<span style="color: green">Likes: <span id="like_count_<%ID%>"><%likes%></span></span>
<span style="color: red">Dislikes: <span id="dislike_count_<%ID%>"><%dislikes%></span></span>
-->
</body>
</html>
答案 0 :(得分:0)
此错误很可能意味着您的网站通过HTTPS提供服务,但您尝试通过HTTP访问jQuery文件,而浏览器正在阻止这种情况发生。所以jQuery永远不会被加载。
解决方案:从jQuery URL的开头删除[63] => Array
(
[0] => Array
(
[date] => 2016-04-28
[usr] => 1
)
[1] => Array
(
[date] => 2016-05-15
[usr] => 1
)
[2] => Array
(
[date] => 2016-06-20
[usr] => 1
)
[3] => Array
(
[0] => Array
(
[date] => 2016-06-20
[usr] => 90
)
)
:
http:
这将确保通过http或https检索jQuery文件,具体取决于您的网站访问方式。