使用jQuery + ajax加载Vimeovideo

我正在使用带有jQuery的OEMBED api阅读Vimeovideo时遇到麻烦。

我的javascript是

function loadVideo(params, callback) { $.ajax({ type : "GET", url : "http://www.vimeo.com/api/oembed.json", data : params, dataType : "json", success : function(result) { alert("calling callback"); callback(result); }, error : function(error) { var s = ""; $.each(error, function(name, value){ s += name + ": " + value + "\n"; }); alert(s); } }); }; 

我就这样称呼这个function

  loadVideo({ "url" : $(this).attr("url"), "title" : $(this).attr("show-title"), "byline" : $(this).attr("show-byline"), "portrait" : $(this).attr("show-portrait"), "color" : "ffffff", "width" : 120 }, function(result) { alert("Setting video content"); $(this).html(unescape(result.html)); }); 

其中$(this)是必须加载video的元素。

检查请求

  Request URL:http://vimeo.com/api/oembed.jsonurl=https%3A%2F%2Fvimeo.com%2F38578157&title=false&byline=false&portrait=false&color=ffffff&width=120&callback=%3F Request Headers Referer:http://localhost:8080/artwriter/art User-Agent:Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1 Query String Parameters url:https://vimeo.com/38578157 title:false byline:false portrait:false color:ffffff width:120 

这个请求看起来是正确的(如果我在浏览器中复制并粘贴,我会得到这个json结果

 {"type":"video","version":"1.0","provider_name":"Vimeo","provider_url":"http:\/\/vimeo.com\/","title":"Test video 1","author_name":"Stefano Cazzola","author_url":"http:\/\/vimeo.com\/user10866085","is_plus":"0","html":" \n\n\n","width":120,"height":90,"duration":165,"description":"","thumbnail_url":"http:\/\/b.vimeocdn.com\/ts\/265\/600\/265600694_100.jpg","thumbnail_width":100,"thumbnail_height":75,"video_id":38578157} 

然而出了问题,我最终在ajax错误回调。

有任何想法吗?