Wednesday, January 31, 2007

The problem with AJAX

AJAX is the buzz on the web these days and as you know, it's supposed to allow a site to retrieve some XML data from some place and use it to render a part of a web page without having to load the entire page. And XML data is just everywhere on the web, most easily found as a feed, like RSS. So there I was thinking of pulling the RSS feed from my blog and then using it to build a dynamic list of entries to put on my site. Sounds cool doesn't it? So what's the problem?

Well, it's actually more of a limitation that a problem . The limitation is that the RSS feed must be on the same domain as my website, since cross-domain XMLHttpRequests are not allowed for security reasons (I haven't read up on this but since all the browsers out there restrict this, it must be a bad thing).

So is my idea shot down? At times like this I usually turn to Google for the answer; this time the answer came from Google, literally, in the form of another one of their nifty APIs. Since Blogger is part of Google, it's no surprise they have APIs for everything including flushing the toilet! What's surprising is how easy it was to use, all it takes is one line and one callback function to render the data, really slick.

Anyways, the page that I was reading is this one http://code.google.com/apis/gdata/json.html Specifically I used the JSON-in-script method to list my latest blog headings on my site now =)

No comments: