我已在本地服务器上部署此插件 http://jquery-plugins.net/FeedEk/FeedEk.html
它有效但我看不到任何PHP脚本:如果没有跨域问题它怎么能运行?
答案 0 :(得分:2)
它使用google api,可以交叉域名=)
http://ajax.googleapis.com/ajax/services/feed/load?....
看看yql
var yql=function(a,b){
return 'http://query.yahooapis.com/v1/public/yql?q='+
encodeURIComponent('select * from '+b+' where url=\"'+a+'\"')+
'&format=json';
};
使用
var crossdomainurl=yql(url,(xml,json,html,feed,rss...))
返回(xml,json,html,feed,rss ...)的交叉域网址
现在你可以毫无问题地使用xhr
在这种情况下,xhr.response总是返回一个json。
完整示例:
var x=function(a,b,c){c=new XMLHttpRequest;c.open('GET',a);c.onload=b;c.send()},
yql=function(a,b){return 'http://query.yahooapis.com/v1/public/yql?q='+encodeURIComponent('select * from '+b+' where url=\"'+a+'\"')+'&format=json';};
x(yql('PUTFEEDURLHERE','xml'),function(){console.log(JSON.parse(this.response))})
答案 1 :(得分:1)
略读the source code表明它使用的是JSON-P API。
url: "http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=" + def.MaxCount + "&output=json&q=" + encodeURIComponent(def.FeedUrl) + "&hl=en&callback=?",