Sometimes we face cross domain error like XMLHttpRequest cannot load [URL]. Origin [YOUR WEBSITE] is not allowed by Access-Control-Allow-Origin while fetching data from rss feeds directly through the browser.
Here the browser security prevents direct fetching of data from other domains unless the domain host includes the Access-Control-Allow-Origin header.So the basic solution is to use a proxy.Two types of proxies can be used
1.Same Domain Proxy:-Here the client-side code can talk asynchronously to servers on the same origin as the page.
2.JSOP Proxy:-In this case you can use proxies hosted on other domains which provide JSONP responses.Examples: YQL, Google feed API
How to use YQL to fetch data from rss/xml feeds:
1.In the fisrt step to fecth data loacaly,create yql proxy by using
2.Replace your xml/rss feed in the place of url.
3.Use JSON to store the data from feed.
Example:
var yql = 'http://query.yahooapis.com/v1/public/yql?' + 'q=select%20*%20from%20rss%20where%20url%3D%22'+ encodeURIComponent('http://www.engadget.com/rss.xml')+ '%22&format=xml&callback=?'; $.getJSON(yql, function(data){ alert(data.results); });