Fancybox返回“所请求的内容无法加载。请稍后再试。“ [英] Fancybox returning " The requested content cannot be loaded. Please try again later."

查看:1674
本文介绍了Fancybox返回“所请求的内容无法加载。请稍后再试。“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 Fancybox 在模式框中播放YouTube视频



我的问题是我不断收到请求的内容无法加载,请稍后再试。



模式框弹出,所以我知道脚本正在运行,这可能是我的API调用的一个问题...这是我的电话:

 < script type =text / javascript> 
$(document).ready(function(){

/ *这是基本的 - 使用默认设置* /

$(a.fancybox) .fancybox({
'hideOnContentClick':true
});

/ *这是YouTube视频的不可信的方法* /

$(a [rel = fancyvideo])。fancybox({
overlayShow:true,
frameWidth:640,
frameHeight:360,
});
});
< / script>


解决方案

你有没有任何 ;< code> class =fancybox rel =fancyvideo ?如果你这样做,那么你会把Fancybox绑定到这两个元素,Fancybox可能不会这样。尝试取出这个:

  $(a.fancybox)。fancybox({
'hideOnContentClick' true
});

看看刚才的第二个就会发生什么。



更新:奇怪。演示(http://chadly.net/demos/video-lightbox.html)正在生成与您的页面不同的HTML,演示构建了一个< object data = ...> ,但是你的构建一个< object>< embed src =youtube-url> 你在说:

  type:'swf'


,这就是< object>< embed> ...< / embed>< / object> code>东西来自。然而, href 指向一个普通的旧YouTube视频观看HTML页面,而 href 最终为 src 属性为< embed> 。嵌入YouTube视频的网址与视频的HTML页面不同,这可能是您的问题的根源。



尝试替换 href ,如下所示:

  http://www.youtube.com/watch?v = QmVvgSfdmJQ 

如下所示:

  http://www.youtube.com/embed/QmVvgSfdmJQ 

第一个是YouTube的纯HTML页面,第二个是可嵌入的SWF。



更新2 :您正在工作的示例来自Fancybox 1.0.0,但您使用的是1.3.4,1.0.0对YouTube的一些特殊检查不在以后的版本中:

  // ... 
} else if(url.match(/youtube\.com\/watch/i)){
// ...

这是从1.0.0开始,之后的代码 else if 重写HTML页面URL(例如 http://www.youtube.com/watch?v= QmVvgSfdmJQ )到旧的可嵌入SWF网址(例如 http://www.youtube.com/v/QmVvgSfdmJQ )。这个版本的问题也解释了为什么这个演示产生的不同于你的HTML。



所以,你有一些版本的问题,其他的一切。 b

Using Fancybox to play youtube videos in a modal box.

My Problem is that I keep getting "The requested content cannot be loaded. Please try again later."

The modal box is popping up so I know the script is running, it might be a problem with my API call... here is my call:

<script type="text/javascript">
$(document).ready(function() {

            /* This is basic - uses default settings */

            $("a.fancybox").fancybox({
                'hideOnContentClick': true
            });

            /* This is a non-obtrustive method for youtube videos*/

            $("a[rel=fancyvideo]").fancybox({
                overlayShow: true,
                frameWidth:640,
                frameHeight:360,
            });
        });
</script>

解决方案

Do you have any <a>s with both class="fancybox" and rel="fancyvideo"? If you do then you'll be binding Fancybox to those elements twice and Fancybox might not like that. Try taking out this one:

$("a.fancybox").fancybox({
    'hideOnContentClick': true
});

And see what happens with just the second one in place.

UPDATE: Strange. The demo (http://chadly.net/demos/video-lightbox.html) is producing different HTML than your page, the demo builds an <object data=...> but yours builds a <object><embed src="youtube-url"> thing. You're saying:

type: 'swf'

in your Fancybox binding, that's where the <object><embed>...</embed></object> stuff comes from. However, the href points at a plain old YouTube video viewing HTML page and that href ends up as the src attribute for the <embed>. The URL for embedding a YouTube video isn't the same as the video's HTML page and that's probably the source of your problem.

Try replacing the href that looks like this:

http://www.youtube.com/watch?v=QmVvgSfdmJQ

with one like this:

http://www.youtube.com/embed/QmVvgSfdmJQ

The first is the plain HTML page for YouTube, the second is the embeddable SWF.

UPDATE 2: The example you're working from is for Fancybox 1.0.0 but you're using 1.3.4, 1.0.0 has some special checks for YouTube that aren't present in later versions:

//...
} else if (url.match(/youtube\.com\/watch/i)) {
//...

That's from 1.0.0 and the code after that else if rewrites the HTML page URL (e.g. http://www.youtube.com/watch?v=QmVvgSfdmJQ) to the older embeddable SWF URL (e.g. http://www.youtube.com/v/QmVvgSfdmJQ). This version problem also explains why the demo was producing different HTML than your's.

So, you have some version problems on top of everything else.

这篇关于Fancybox返回“所请求的内容无法加载。请稍后再试。“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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