无法进行跨域Ajax调用

ant*_*paw 3 javascript ajax jquery youtube-api cross-domain

$(document).ready(function(){$ .ajax({url:" http://gdata.youtube.com/feeds/api/users/zdf/playlists?v=2 ",输入:"GET", success:function(msg){console.log(msg);}});});

我收到此错误"XMLHttpRequest无法加载http://gdata.youtube.com/feeds/api/users/zdf/playlists?v=2 "

如何进行跨域ajax调用以从api获取xml?

jAn*_*ndy 6

您无法进行跨域调用以获取XML.您唯一选择接收数据跨域的是JSON-P.

same origin policy限制对外国域直接访问(AJAX/I帧),json-p使用dynamic script tag insertion来解决此问题.

看看http://api.jquery.com/jQuery.getJSON/.JSON-P也在那里.

编辑

http://code.google.com/intl/de-DE/apis/youtube/2.0/developers_guide_json.html

为你而制作!