Introducing AHAH
You saw in Lesson 12, "Returning Data as Text," just how much can be achieved with an Ajax application without using any XML at all. Many tasks, from simply updating the text on a page to dealing with complicated data structures, can be carried out using only the text string whose value is returned in the XMLHTTPRequest object's responseText property.
It is possible to build complete and useful applications without any XML at all. In fact, the term AHAH (Asynchronous HTML and HTTP) has been coined for just such applications.
This lesson takes the concepts of Lesson 12 a little further, examining in more detail whereand howAHAH can be applied.
Note
![]() | This technique, a kind of subset of Ajax, has been given various acronyms. These include AHAH (asynchronous HTML and HTTP), JAH (Just Asynchronous HTML), and HAJ (HTML And JavaScript). In this book we'll refer to it as AHAH. |
Why Use AHAH Instead of Ajax?
There is no doubt that XML is an important technology with diverse and powerful capabilities. For complex Ajax applications with sophisticated data structures it may well be the bestor perhaps the onlyoption. However, using XML can sometimes complicate the design of an application, including:
Work involved in the design of custom schemas for XML data.
Cross-browser compatibility issues when using JavaScript's DOM methods.
Performance may suffer from having to carry out processor-intensive XML parsing.
Using AHAH can help you avoid these headaches, while offering a few more advantages too:
Easy reworking of some preexisting web pages.
HTML can be easier to fault-find than XML.
Use of CSS to style the returned information, rather than having to use XSLT.
Note
![]() | XSLT is a transformation language used to convert XML documents into other formatsfor example, into HTML suitable for a browser to display. |
In the following sections we'll package our AHAH scripts into a neat external JavaScript file that we can call from our applications.