I've learned it's good form to always show your viewers exactly where you're leading them to begin with, so here are a couple of examples of the Ajax style RSS ticker I'll be discussing how to create:
Some blank space added here to preventing hopping.
Each ticker on the page can be invoked independently, for example:
<script type="text/javascript"> //rss_ticker(RSS_id, cachetime, divId, divClass, delay, optionalswitch) new rss_ticker("CNN", 60, "cnnbox", "cnnclass", 2000) </script>A quick overview of how our Ajax RSS ticker works:
- A very simple PHP script is used to get the contents of an RSS file online and save it locally on the server for caching, unparsed in any way.
- Ajax is used to fetch the contents of the RSS file produced by the PHP script.
- JavaScript receives the contents of this RSS file (via Ajax), then parses it using standard DOM methods before displaying the feed in any manner the webmaster desires.
Ok, so lets get started! First stop, creating a PHP script for fetching the contents of a file online.