0

以下代码 - 带有缩略图的 youtube 加载器 - 在 FF 和 Chrome 中有效,但在 IE 中无效。我想知道这是否与 Jsonc 通话有关。我听说最好在 IE 中使用 Jsonp。尽管如此,我还是想在我的项目中使用 Jsonc。请问有人能告诉我这个问题吗?我被困住了...

<script>
var player;

$(document).ready(function(){

    window.onYouTubeIframeAPIReady = function() {
        player = new YT.Player('video', {
            events: {
                'onReady': function () {
                     $.getJSON("http://gdata.youtube.com/feeds/api/users/diasporaduo/uploads?v=2&alt=jsonc", function (json) {
                         videoid = json.data.items[0].id;
                            player.cueVideoById(videoid);
                    });
                }
            }
        });
    }

});


</script>
4

1 回答 1

0

What you're trying to do is make a CORS call, and that's not supported in Internet Explorer versions earlier than 10: http://apiblog.youtube.com/2012/05/unlocking-javascripts-potential-with.html

You should use JSONP if you care about compatibility with older versions of IE. jQuery makes that pretty easy with its $.ajax() method.

于 2013-01-24T01:47:27.003 回答