1

I am using $.getJSON to load in a video gallery from Vimeo and it works fine in all browsers, except in any version of IE. I cannot figure out what I am doing wrong.

Here is the .js file where the getJSON is running:

console.log('file load');

var jsonURL = 'http://vimeo.com/api/v2/album/1822727/videos.json';

$.getJSON(jsonURL, function(data){
  $.each(data, function (index, value) {
    var videoID = value.id;
    var videoThm = value.thumbnail_large;
    $('#galThms').prepend('<li id="thm' + videoID + '" style="background-image:url(' + videoThm + ');"><a title="' + videoID + '" href="#playVideo"></a></li>');
    console.log('json success');
    });
    $(function() {
      $('.galleryThms a').click(function() {
        $('#loadVideo').slideDown();
        $('.galleryThms a').html('');
        $(this).html('<div class="currentOverlay"><ul><li></li><li></li><li></li><li></li><li></li><li></li><li></li></ul></div>');
        $('<div class="watchedVideo"></div>').appendTo($(this).parent());
        $('.galleryThms a').css('background-image', 'url(/images/gallery-play-button.png)');
        $(this).css('background-image', 'none');

        //Embed Video
        var vimeoEmbedID = $(this).attr( "title" );
        $('#loadVideo').html('<iframe src="//player.vimeo.com/video/' + vimeoEmbedID + '?title=0&amp;byline=0&amp;portrait=0&amp;color=57bec7&amp;autoplay=1" width="1920" height="1080" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>');

     });

  });
 });

The live example can be found here: http://wavesmediagroup.com/weddings/portfolio/

4

1 回答 1

1

这是一个跨域问题。此处的这篇文章http://e-mats.org/2010/01/jquery-getjson-and-the-same-origin-policy详细解释了您只需添加:

?callback=?

…在你的跨域 JSON 文件的末尾,其余的由 jquery 处理。所以我的网址现在看起来像:

http://vimeo.com/api/v2/album/1822727/videos.json?callback=?

……而且效果很好!

于 2014-03-28T00:13:57.327 回答