Reading Data from an XML File for a Dynamic AJAX-based Banner System
(Page 1 of 4 )
Undeniably, AJAX has introduced a noticeable impact into the development of rich web applications, and consequently there are many enthusiastic web developers that continue discovering more and more creative uses for this powerful technology. Particularly, in this series of articles this "creativity" is focused entirely upon building an AJAX-driven banner application for displaying, on the browser, a certain number of banners via a few HTTP requests made in the background.
Introduction
Having already introduced the subject of this series, it'd be useful to recall, at least briefly, the topics covered in the first article, so you can hopefully grasp much more easily the improvements that I plan to incorporate into the original banner application. In the preceding tutorial of the series, I went through the complete development of an AJAX-based program aimed at implementing a basic web-based advertising system. The system was comprised of a determined number of dynamic banners, displayed on the browser at a predefined time interval.
Of course, it's quite clear that one of the most straightforward methods for fetching contents (text and XML files, images, etc.) from the web server via AJAX at a predetermined interval of time involves creating a simple JavaScript timer, usually implemented via the popular "setTimeout()" method.
In this case, I used this useful JavaScript method as part of the banner application's logic to display the banners in a specified sequence over time, but as you might guess, this feature can be easily changed if you want to display the mentioned banners randomly, instead of using a fixed time interval.
So far so good. At this stage I firmly believe that the concepts involved in building this AJAX-based banner system have been properly understood, so it's time to speak specifically of the topics that I'm going to treat over the course of this second article of the series. In basic terms, I'm going to introduce some minor modifications to the original application (particularly within its behavior layer) so it can read all of the banner-related data directly from an XML file. In this way it will take advantage of the XML part exposed by the AJAX technology. Sounds pretty logical, right?
Hopefully, after you learn how to move all of the banner data to a simple XML file, you'll have at your disposal a fully-functional AJAX application that will be capable of displaying a set of dynamic banners fetched from the web server in the form of well-structured XML data.
So are you ready to see how implement this XML-based banner system with AJAX? Let's not waste any more time in preliminaries; let's begin now!
Next: Reintroducing the source files of the initial banner application >>
More JavaScript Articles
More By Alejandro Gervasio