Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery Fancybox加载动画不会触发_Jquery_Fancybox - Fatal编程技术网

Jquery Fancybox加载动画不会触发

Jquery Fancybox加载动画不会触发,jquery,fancybox,Jquery,Fancybox,fancybox函数有什么特别的原因吗 $.fancybox.showActivity(); 在我的脚本中抛出错误?是否有调用函数的特定顺序?该功能用于在将内容加载到弹出窗口之前显示加载图像。这是我的密码: $(".info_button").click(function () { var pictid_browse = $(this).parent().find('#pictid').val(); $.fancybox.showActivity(); $.ajax(

fancybox函数有什么特别的原因吗

$.fancybox.showActivity();
在我的脚本中抛出错误?是否有调用函数的特定顺序?该功能用于在将内容加载到弹出窗口之前显示加载图像。这是我的密码:

$(".info_button").click(function () {

    var pictid_browse = $(this).parent().find('#pictid').val();
    $.fancybox.showActivity();
    $.ajax({
                url: "ajax.html",
                type: "POST",
                async:false,
                data: ({f:"get_info",pictid:pictid_browse}),
                success: function(data){
    $.fancybox({
                    'autoDimensions'    : false,
                'width'                 : 950,
                'height'                : 'auto',
                'transitionIn'      : 'none',
                'transitionOut'     : 'none'
            });
                $.fancybox({content:data,'autoDimensions':true,'scrolling':'no',});


    }
    });

    return false;
    });
我得到的错误是:

Uncaught TypeError: Object function () {
        F.open.apply( this, arguments );
    } has no method 'showActivity'

Fancybox版本:2.1.3

更新:

我不知道发生了什么但如果我

$.fancybox.showLoading();

$(".info_button").click(function () {
然后激发并显示动画。但我需要它在类的项被单击后发生

以下解决方案似乎也无法解决问题:

    $(".info_button").bind('click', function (e) {
  e.stopPropagation(); e.preventDefault();
}
研究表明,如果删除以下代码,则会触发加载:

 $.fancybox({
content:data,
                'autoDimensions'    : true,
            'width'                 : 'auto',
            'height'                : 'auto',
            'transitionIn'      : 'none',
            'transitionOut'     : 'none',
            'scrolling':'no'
        });
这可能意味着fancybox在包含在ajax函数中时无法正常工作,但我不知道为什么它的apidock有点过时了(它用于1.x.y)

因此,如果您使用:

  • 要使用的旧1.x.y:
    $.fancybox.showActivity()
  • 您想要使用的较新的2.x.y:
    $.fancybox.showLoading()
您可以找到有关2.x.y文档和其他内容的文档。他们保留网站“因为两个版本(1.x和2.x)有不同的许可证方案”(thx到)。你可以报告,mb你从他们那里得到一颗金星:)

==========问题更新后回答==========

如果看不到完整的html和js,我无法确定,但您可以尝试:

$(".info_button").bind('click', function (e) {
  e.stopPropagation(); e.preventDefault();
}

问题似乎出在双重fancybox调用中。工作代码如下:

    $('.info_button').bind('click', function() {
    var pictid_browse = $(this).parent().find('#pictid').val();
    $.fancybox.showLoading();
    $.ajax({
        type:"POST",
        cache:false,
        url:"ajax.html",
        data:({f:"get_info",pictid:pictid_browse}),
        success: function(data) {
            $.fancybox({content:data,'autoDimensions':true,'scrolling':'no'});
        }
    });
    return false;
});
你可以这样做

    <style>
     #fancybox-loading{z-index:999999999;}
    </style>



     <script>
                       $.fancybox({
                                'href'          :your_url,  
                                'width'         : 900,
                                'height'        : 600,
                                'scrolling' : 'auto',
                                'type'              : 'iframe',
                                'titleShow'     : false,
                                'onComplete' : function() {
                                    $.fancybox.showActivity();
                                    $('#fancybox-frame').load(function() {
                                        $.fancybox.hideActivity();
                                    });
                                }
                        })
</script>

#fancybox加载{z-索引:99999999;}
$.fancybox({
“href”:您的url,
“宽度”:900,
‘高度’:600,
“滚动”:“自动”,
'type':'iframe',
“标题秀”:假,
“onComplete”:函数(){
$.fancybox.showActivity();
$('#fancybox frame').load(函数(){
$.fancybox.hideActivity();
});
}
})

这是一个很好的提示!但我仍然无法使加载图标出现。不过这次我有个bo js错误…你的fancybox版本号是多少?
fancybox.net上的apidock有点过时了
。。。嗯,不是。适用于v1.3.4及以下版本,而适用于新版本2.x及以上版本。Fancybox v1.3.x API选项、方法和回调与v2.x不兼容,反之亦然。。。。为您正在使用的版本使用正确的选项。我认为现在,您缺少加载图标的图像。你确定你也复制了它吗
fancybox_loading.gif
他们之所以保留网站是因为SEO我认为
:保留两个网站的原因是因为这两个版本(1.x和2.x)有不同的许可证方案。更新了我的答案,如果你更新了你的问题,请对此进行评论。你现在看到任何错误了吗?也许可以尝试注释里面的所有内容。单击函数并只保留
$.fancybox.showLoading()行。发生了什么?但如果您查看Firebug控制台(),是否会看到任何错误消息(没有注释所有内容)?可能是
数据
不适合fancybox,它出错了。或者,如果您运行这个本地调用,ajax调用将立即完成,因此您不能期望看到加载的图像。我在核心问题上帮了你,这个网站不是用来教人的。我理解,但是没有js错误,代码也没有显示加载图像。我将尝试重新构建ajax调用以适应fancybox。无论如何,我感谢你的帮助:)
    <style>
     #fancybox-loading{z-index:999999999;}
    </style>



     <script>
                       $.fancybox({
                                'href'          :your_url,  
                                'width'         : 900,
                                'height'        : 600,
                                'scrolling' : 'auto',
                                'type'              : 'iframe',
                                'titleShow'     : false,
                                'onComplete' : function() {
                                    $.fancybox.showActivity();
                                    $('#fancybox-frame').load(function() {
                                        $.fancybox.hideActivity();
                                    });
                                }
                        })
</script>