Apr
21st

RSS with an Ajax Twist

Files under AJAX Design, Web 2.0 | Posted by MixedSoup | 153 views

Personally, one of the simplest yet amazing web tools today is the RSS. This tool could be found everywhere – in blogs, news, podcasts and videos. Users could even configure Google to alert them via RSS with the keywords they prefer. In fact, Google Reader is an elaborate web based program that gathers all the RSS feeds preferred by the user. You do not have to go back and forth to the webpage for update. The news is sent directly to your mail, or to your reader depending on your preferences.

On the other hand, Ajax is an emerging technology that has practically influenced all facets of web technology. Fortunately enough, it has also influenced RSS opening doors to almost infinite possibilities. When a developer is very creative with Ajax, the developer could do so many things and RSS could be recreated to a new life. When we combine RSS and Ajax, we end up with an Ajax based feed. One of cool things you could actually create with Ajax and RSS is a news or blog ticker. This ticker will practically refresh at a pace set by the developer. It will constantly feed the latest news from the chosen RSS by the developer. The developer can place an almost unlimited number of RSS as long as they could be handled by the server.

To build an Ajax based ticker with RSS, you need four things: PHP, Ajax, JavaScript and RSS. Their role in developing an Ajax based ticker will be shown on the following steps:

Step #1: Build a PHP Script for RSS Feed – the first thing you would do of course is to build a function where PHP could fetch the information. The question you would probably ask is: why PHP? PHP is a lightweight code compared to HTML plus it has the ability to cache the RSS file for a certain amount of time. PHP could also effectively transfer the fetched information to JavaScript.

Step #2: Connecting the server and the client using Ajax – transporting information from PHP to JavaScript requires a bridge. This is where Ajax makes its appearance. Using XMLHttpRequest to the server, Ajax should be able to handle data coming from PHP and transmit them to JavaScript. It should be noted that the data transmitted could either be XML or JSON and that should be left to the developer’s preferences. XML could be used and JSON does the same job with the same efficiency. Of course when you are dealing with IE you have to add ActiveXObject to ensure browser compatibility.

Step #3: Getting them all together – to do this you need to configure JavaScript on how it would render the information. That means JavaScript will lay out the data output: when will the ticker change information or how long the new feed will be displayed.

Of course you can modify these by changing color or adding better effects for that “artsy” look in your Ajax based RSS ticker. As long as you are aware of different Ajax functions and RSS capabilities, you can expand your options.

Related Posts

Post a Comment