未捕获的类型错误:对象[对象的对象]有没有办法“的fancybox” [英] Uncaught TypeError: Object [object Object] has no method 'fancybox'

查看:215
本文介绍了未捕获的类型错误:对象[对象的对象]有没有办法“的fancybox”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用一个jQuery插件时,得到以下错误。

奇怪的是,这是正常使用(现在仍然如此)时,它的一个基本的HTML文件中,但是当我开始填充物的用PHP我得到这个错误。

`未捕获的类型错误:对象[对象的对象]有没有办法fancybox'`

该错误是发生在包括行...

  $('#显示滑块)。的fancybox(函数(){
 

下面是我的HTML。

 < PHP
    require_once('包括/的functions.php');

    的$ id = $ _GET ['身份证'];
    连接();

    $ Q =SELECT * FROM网址其中id = $编号;
    $ R =请求mysql_query($ Q);

    如果($ R === FALSE){
        死亡(mysql_error());
    } 其他 {
        $ ARR = mysql_fetch_array($ R);
    }

    则mysql_close();
?>
< HTML>
< HEAD>
<冠军>< = $ ARR [2]>< /标题>
<链接相对=样式类型=文/ CSS的href =/包括/的fancybox / jquery.fancybox-1.3.4.css媒体=屏幕/>
<链接相对=样式类型=文/ CSS的href =/包括/ CSS / style.css的媒体=屏幕/>
<脚本类型=文/ JavaScript的SRC =htt​​ps://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js>< / SCRIPT>
<脚本类型=文/ JavaScript的SRC =/包括/的fancybox / jquery.fancybox-1.3.4.pack.js>< / SCRIPT>
<脚本类型=文/ JavaScript的>
    功能Go(){
        $('#显示滑块)。的fancybox(函数(){
            $('#滑盖)的css(显示,内联)。
        });

        $('#显示滑块)点击();
    }
< / SCRIPT>
< /头>
<身体GT;
&所述; IFRAME SRC =&其中; = $改编[1]≥? WIDTH =100%高度=100%的onload =去();>
  < P>您的浏览器并不支援iframe< / P>
< / IFRAME>
<一个ID =显示滑块的href =#滑的风格=显示:无;>内联< / A>
< D​​IV的风格=显示:无;>
    < D​​IV ID =滑块>
        &所述;?= $改编[3]≥
    < / DIV>
< / DIV>
< /身体GT;
< / HTML>
 

编辑:它看起来像我的.htaccess被搞乱事情有点

  RewriteEngine叙述上
重写规则([0-9] +)show.php?ID = $ 1
 

什么是应该做的只是采取有号码的URL,并派他们到show.php,这就是我上面张贴的文件。

当我访问我的CSS或在浏览器中的JavaScript文件,我会发送到show.php页面代替。

编辑2:是的,这是htaccess的

下面是新版本,一切是伟大的工作了。

  RewriteEngine叙述上
重写规则^([0-9] +)$ show.php?ID = $ 1
 

解决方案

尝试改变的js文件的顺序。 地方块的javascript code在体内和的fancybox-1.3.4.pack.js之前。 对于我的作品, 祝你好运!

I'm getting the following error when trying to use a plugin for JQuery.

Strangely, this was working perfectly (and still does) when it's inside a basic HTML file, but when I start filling things in with PHP I get this error.

`Uncaught TypeError: Object [object Object] has no method 'fancybox'`

The error is occurring on the line that includes...

 $('#show-slider').fancybox(function() {

Here's my html.

<?php
    require_once('includes/functions.php');

    $id = $_GET['id'];
    connect();

    $q = "select * from urls where id = $id";
    $r = mysql_query($q);

    if($r === FALSE) {
        die(mysql_error());
    } else {
        $arr = mysql_fetch_array($r);
    }

    mysql_close();
?>
<html>
<head>
<title><?=$arr[2]?></title>
<link rel="stylesheet" type="text/css" href="/includes/fancybox/jquery.fancybox-1.3.4.css" media="screen" />
<link rel="stylesheet" type="text/css" href="/includes/css/style.css" media="screen" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script type="text/javascript" src="/includes/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
<script type="text/javascript">
    function go() {
        $('#show-slider').fancybox(function() {
            $('#slider').css('display', 'inline');
        });

        $('#show-slider').click();
    }
</script>
</head>
<body>
<iframe src="<?=$arr[1]?>" width="100%" height="100%" onload="go();">
  <p>Your browser does not support iframes.</p>
</iframe>
<a id="show-slider" href="#slider" style="display: none;">Inline</a>
<div style="display: none;">
    <div id="slider">
        <?=$arr[3]?>
    </div>
</div>
</body>
</html>

EDIT: It looks like my .htaccess is messing with things a bit.

RewriteEngine On  
RewriteRule ([0-9]+) show.php?id=$1

What it should be doing is only taking URLs that are numbers and sending them to show.php, which is the file I posted above.

When I visit my css or javascript files in my browser, I get sent to the show.php page instead.

EDIT 2: Yep, it was the htaccess.

Here's the new version and everything is working great now.

RewriteEngine On  
RewriteRule ^([0-9]+)$ show.php?id=$1

解决方案

Try to change the order of js files. place block of javascript code in body and the "fancybox-1.3.4.pack.js" before . for me works, good luck!

这篇关于未捕获的类型错误:对象[对象的对象]有没有办法“的fancybox”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆