The Reengineered Clients

The biggest decision at this point is whether to implement the server-side application and the Ajax client within the same pages. This was the approach used in Chapter 7, but it doesn't always provide the best value for an application.

There are times when a user may have scripting enabled, but would choose to work with the nonscript-enabled version of an application. People using screen readers would most likely prefer the nonscripted version, but may still have scripting turned on. After all, not all scripting pushes elements in the page around. Then there are folks using some oddball browser that does strange things to the page, or others who really aren't fond of Ajax (No! How can that be!), and it's nice to be able to give all these web page readers a choice.

The Script-Free Application

Both the scripting and nonscripting versions of the application are served from the same intro page, which uses PHP to list out all the links to the "static" photo pages (effectively caching the Flickr request to get the original set of photos), as well as providing a link to the slideshow. The links pass all the information necessary to populate the page in the server-side application, including the photo identifier and other identifying information for the image URL. Example 9-11 includes the code for this page.

Example 9-11. Nonscript-dependent introduction page

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> ...

Get Adding Ajax now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.