jQuery错误"u未定义"; [英] Jquery error "u is undefined"
问题描述
为什么我在Firebug中收到错误消息"u is undefined"?
Why am I getting an error in Firebug "u is undefined"?
我的页面包括显示照片和照片库,这是PHP代码中使用"break"分隔的特殊部分.
My page consists of a display of photos and photo gallery as a special separate section in the PHP code divided using the "break".
使用"Fancybox.js"显示照片和画廊.
Photos and photo galleries are displayed using the "Fancybox.js".
第一次尝试打开照片时,一切正常,但是刷新页面后再次执行时,Firebug显示错误"u is undefined".
The first time when I try to open a photo, everything works fine but when I do it again after I refresh the page the Firebug display error "u is undefined".
我用于菜单的Jquery显示页面的这些单独部分:
The Jquery for the menu that I'm using for display these separate part of the page:
$(document).ready(function(){
$(".menu_rfr").bind('click', function() {
$("#main").html('<img src="img/spin.gif" class="spin">');
location.replace($(this).attr('rel'));
});
$(".menu_clickable").bind('click', function() {
$("#main").html('<img src="img/spin.gif" class="spin">');
$("#main").load($(this).attr('rel'), function(event) {
});
$(".menu_clickable").unbind("click");
});
});
简化的PHP代码如下:
The simplified PHP code looks like:
<?
if (!isset($a)) $a = '';
switch($a)
{
case 1:
default:
?>
<div class="menu_clickable prof_link" id="prof_info" rel="?a=2">Photos</div>
<div class="menu_clickable prof_link" id="prof_info" rel="?a=3">Gallery</div>
<div id="main"></div>
<?
break;//photos
case 2:
?>
<script type="text/javascript">
$("a.group").fancybox({
'titlePosition' : 'over',
'overlayShow':false
});
</script>
<?
<a href="1.jpg" id="group" class="group"><img src="tmb/1.jpg" border="0"></a>
<?
break;
case 3: // photo gallery
?>
<script type="text/javascript">
$("a.groupg").fancybox({
'titlePosition' : 'over',
'overlayShow':false
});
</script>
<?
<a href="2.jpg" id="groupg" class="groupg"><img src="tmb/2.jpg" border="0"></a>
<?
break;
}
?>
正如我所说的,这是一个简化的代码,可能其中包含一些错误.我只是想展示我在哪里以及如何使用Fancybox.
As I said this is a simplified code, and probably there are some errors in it. I just wanted to show where and how I'm using Fancybox.
页面顶部菜单的jquery代码与fancybox的jquery代码之间是否存在冲突,或者有其他一些原因导致我在打开另一部分后在Firebug中仍然出现错误"u is undefined" PHP页面并尝试重新打开照片?
Is there a conflict between the jquery code for the menu at the top of the page and this for fancybox or there is some other reason why I keep getting an error in Firebug "u is undefined" after opening the other part of the PHP page and attempts to re-opening photos?
推荐答案
查看HTML源代码,并确保没有两次声明FancyBox.我只是在萤火虫中弹出了完全相同的错误,这就是我在源代码中找到的:
View your HTML source and make sure you don't have FancyBox declared twice. I just had the exact same error pop up in firebug and this is what I found in my source:
<script language="javascript" type="text/javascript" src="./ext_scripts/jquery.fancybox-1.3.1/fancybox/jquery.fancybox-1.3.1.pack.js"></script>
<link rel="stylesheet" href="./ext_scripts/jquery.fancybox-1.3.1/fancybox/jquery.fancybox-1.3.1.css" type="text/css" media="screen" />
<script language="javascript" type="text/javascript" src="./ext_scripts/jquery.fancybox-1.3.1/fancybox/jquery.fancybox-1.3.1.pack.js"></script>
不确定为什么会发生,但是不幸的是,如果像我不幸的那样,将include和require_onces嵌套在PHP中,则可以使用一些非常时髦的Javascript引用.
Not sure exactly why it happened, but if you nest your include and require_onces in your PHP like I unfortunately did, you can wind up with some very funky Javascript references.
这篇关于jQuery错误"u未定义";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!