Reputation: 114126
Can JavaScript load an RSS XML feed from Yahoo?
Is client-side JS allowed to access 3rd-party domains?
Upvotes: 5
Views: 3489
Reputation: 36092
You can use the Google Feed API to load RSS in JavaScript from any domain / server. More than just a proxy, it actually serves the RSS content from the Google cache instead of hitting the original server. This could be a lifesaver for small servers that can't handle Slashdot traffic surges.
I used the Feed API for a cross-site RSS access in an article on Silverlight several years ago.
Upvotes: 2
Reputation: 46
You can use the technique outlined in my blog post Unwritten guide to Yahoo Query Langauge
You would query the XML data table with a yql statment like this:
Then you would add a script tag to your html (can be done with document.createElement('script')) with a src http://query.yahooapis.com/v1/public/yql?q={your yql here}&format=json&callback={your function here} where {your yql here} is replace with a URI Encoded version of you yql statment.select * from xml
where url="http://path/to/xml
Upvotes: 2
Reputation: 45
Not directly. You can use Dana's suggestion of proxing the request, or look into a method called JSONP, which essentially wraps the returned JSON object in a custom callback function, requested by a script tag you inject into your DOM. Most API providers support this (including Yahoo's APIs).
Upvotes: 0
Reputation: 15208
An easy way to do this is to proxy the request through the server that your page resides on. Steps are:
On IE 8 and FF 3.1(not certain), it is possible to make these requests through specialized cross site calls, but the last generation of browsers will still cause problems. See:
http://dannythorpe.com/2009/01/15/ie8-cross-domain-request-support-demo/ http://ejohn.org/blog/cross-site-xmlhttprequest/ Feature is restricted in FF 3.0, unclear if it will be back in 3.1
However, the steps above are guaranteed not to run afoul of any browser CSS security, at the expense of some lag and extra hw load on your server.
Upvotes: 2
Reputation: 37231
I'm not sure about JS but I know that you can use one of google's APIs and they have an RSS reader. I know this probably isn't what you want, but if you read through the documentation you may be able to get your answer on how it works.
Upvotes: 0