0

I have deployed this plugin on my local server http://jquery-plugins.net/FeedEk/FeedEk.html

It works but I can't see any php script : how can it work without cross-domain issue ?

user310291
  • 36,946
  • 82
  • 271
  • 487

2 Answers2

2

It uses google api which can crossdomain everything =)

http://ajax.googleapis.com/ajax/services/feed/load?....

take a look at yql

var yql=function(a,b){
 return 'http://query.yahooapis.com/v1/public/yql?q='+
 encodeURIComponent('select * from '+b+' where url=\"'+a+'\"')+
 '&format=json';
};

usage

var crossdomainurl=yql(url,(xml,json,html,feed,rss...))

returns the crossdomain url for (xml,json,html,feed,rss...)

now you can use xhr without any problem

the xhr.response returns always a json in this case.

Full Example:

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))})
cocco
  • 16,442
  • 7
  • 62
  • 77
1

Skimming the source code shows that it uses a 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=?",
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335