Be the first to write a review
Ajax: Ready States, PHP and Arrays
Last week we built a basic filmstrip application using Ajax. It was neat to see the images and descriptions coming in asynchronously, but it wasn’t a very extendable application of Ajax. What if we wanted to add new images? And what about all the hard coded JavaScript? There ought to be something we can do to make this type of application more robust.
In fact, there are a few things that we can do to toward that end. First of all we can make use of a server side language (we’ll use PHP) to figure out how many images (and what they are) on our server. We can also make generous use of arrays, both in JavaScript and PHP to do some of the data handling. Essentially, we want to think in a more object oriented way.
Lastly, we can make use of the xmlHTTPObject’s ReadyState property to keep the user informed of the progress when loading new elements into their view.