这个插件如何阅读没有跨域问题的RSS源? [英] How this plugin can read RSS feeds without cross-domain issue?
本文介绍了这个插件如何阅读没有跨域问题的RSS源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已在我的本地服务器上部署了此插件
http:// jquery-plugins .net / FeedEk / FeedEk.html
I have deployed this plugin on my local server http://jquery-plugins.net/FeedEk/FeedEk.html
它可以工作,但我看不到任何php脚本:它如何工作没有跨域问题? / p>
It works but I can't see any php script : how can it work without cross-domain issue ?
推荐答案
它使用google api可以跨域一切=)
It uses google api which can crossdomain everything =)
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 ...)的交叉域网址
returns the crossdomain url for (xml,json,html,feed,rss...)
现在你可以使用xhr没有任何问题
now you can use xhr without any problem
xhr.response在这种情况下总是返回一个json。
the xhr.response returns always a json in this case.
完整示例:
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))})
这篇关于这个插件如何阅读没有跨域问题的RSS源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文