I want to know how to parse atom feed using jquery.
i had feed url like below
http://www.google.co.in开发者_高级运维/trends/hottrends/atom/hourly
Below is jsfiddle but it's not working
http://jsfiddle.net/sukumar/sWPkT/
To make cross-browser request, see the link I pointed out in my comment.
You can use this code:
<script src="jquery.js"></script>
<script src="jquery.jgfeed.js"></script>
<script>
$.jGFeed('http://twitter.com/statuses/user_timeline/26767000.rss',
function(feeds){
// Check for errors
if(!feeds){
// there was an error
return false;
}
// do whatever you want with feeds here
for(var i=0; i<feeds.entries.length; i++){
var entry = feeds.entries[i];
// Entry title
entry.title;
}
}, 10);
</script>
Don't forget to include Google Feeds API plugin (jquery.jgfeed.js)
Source
If you look in your browser's JavaScript console, you'd probably see something among the lines of:
XMLHttpRequest cannot load http://www.google.co.in/trends/hottrends/atom/hourly. Origin http://fiddle.jshell.net is not allowed by Access-Control-Allow-Origin.
Basically, for security reasons, you can't make an AJAX request from one domain to another. All browsers enforce this.
精彩评论