View Single Post
Old 09-20-2013, 10:29 AM  
fris
Too lazy to set a custom title
 
fris's Avatar
 
Industry Role:
Join Date: Aug 2002
Posts: 55,372
Tip for javascript people: parsing xml/rss feeds without php

I been wanting to parse feeds on a static only site, but usally you have to use a php file to do it, I just realized Google has a feed parsing api, which turns a xml/rss feed into a json object.

Thought I would pass it along.

You basically take

https://ajax.googleapis.com/ajax/ser...main.com/feed/

it turns the feed into a json object.

I put up a jsfiddle demo which grabs the google trends.

Code:
$(function() {
    $.getJSON('https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http://www.google.com/trends/hottrends/atom/feed?pn=p1&num=-1&callback=?&alt=json-in-script', function(data) { 
        $.each(data.responseData.feed.entries, function(i, item) {
	    var title = item['title'];
	    $('#trends').append(title + '<br/>');
        });
    });
});
http://jsfiddle.net/7YDLP/

Hope someone can use this ;)
__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


WP Stuff
fris is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote