Ajax Picture and Text Scroller
by [Your Name Here]
This illustrates a simple Ajax-oriented approach to swap images.
Here are the particulars of this assignment:
-
The showImages.html file is the web page you are looking
at. This files is the one that the
student modifies (or modified) as necessary
for this assignment. In particular, it needs to reference
any additional Javascript files created by the student.
It is okay if changes are made to the style (via CSS) and
structure (within reason). For example, div elements
and/or id attributes could be added if that would be
useful for accessing certain parts of the code by the
Java scripts.
-
The getXML.php file in this same folder gets
a value for fn, the filename for an XML file.
This server-side script responds by reading that file
and responds to the XML request with the entire XML contents.
For this assignment the XML file is named business.xml
(also in this same folder). Thus, the URL for the XML
request is: getXML.php?fn=business.xml
-
When the user first visits this page, your script should get
all of the description elements and randomly choose one
of them to show in the first row of the table (the image
in the first column and the paragraph description in the
second column). Note: the original template shows an image and
some garbage text, but that can be removed from this html.
-
When the user presses the previous or next icons (under the
image panel) you should go to the previous or the next image
in the sequence (and its description). The previous image of the
first image is the last one and the next image after the last one
is the first (i.e., wrap-around sequence).
-
When the user presses the play (loop) icon it sequences to the
next one, over and over, at 5 second intervals. This continues
until the user presses any of the other icons (next, prev, or
stop) or refreshes the page.
-
The only time the request object is sent should be at page
load or reload. Thereafter, your script should be able to
refer back to the entire list of descriptions that it got
when it shows the previous one, the next one, or playing them
in sequence.
You will need to open up and look at the business.xml file to figure
out how to access its parts. Basically, what you need to do is to
create a paragraph object from the paragraph description in the XML
file and then insert that into the table
(i.e., the td with id="descr").
Of course you must also change the image that goes with it
(i.e., the td with id="photo").
Remember to remove what was there before you append the new elements
to the document. Most of these actions take place on a mouseclick
event on the image objects for the icons.