- AHAH
Asynchronous HTML and HTTP, or AHAH, is a method for updating
webpages dynamically usingJavascript , similar to Ajax, but with the difference that the response from the request is used directly without parsing on the clientside. This means that server responses need to be text or already include validXHTML /HTML structure. It is also known as themicroformat rest/ahah.Introduction
Like Ajax, the
XMLHttpRequest functionality is used to initiate a request, but the state-change of the request when the response is received is directed to a function which does not parse the response asXML using theDocument Object Model , but rather inserts the response directly into the intended target element of the document using the non-standard "innerHTML " attribute of elements. The "innerHTML" is a read-/writeable attribute which is supported by the majorweb browser s (or user agents), and was first introduced in Microsoft's Internet Explorer.Considerations
A
best practice approach to using AHAH is that if you are not going to modify the content structure of the XMLHTTP response further, then it is most often recommendable because of ease of use, lesser complexity, improved speed and improved code readability. The "innerHTML" attribute is also widely supported, although it is not part of theW3C DOM recommendations.However, if changes to the response XHTML structure beyond any simple string operations are needed, a DOM centric approach as in Ajax is preferable since references to elements based on the response contents, which then have been appended to the target element, have already been created - and can thus be reused. This consideration will vary from case to case, however, since the complexity of the structure and frequency of changes will dictate performance variations.
Firefox 1.5 will only allow valid element structure being set with "innerHTML", whileFirefox 2, Opera 8.54 andInternet Explorer 6 & 7 will currently allow any string.Also, speed is much improved by using "innerHTML" over manipulating the DOM, and some extensive benchmarks have been performed to prove this.Fact|date=July 2008 So, this might warrant the use of AHAH over Ajax in some cases.
Unfortunately, none of the major web browsers normally return valid
XML from "innerHTML", even if the document type is set to XHTML 1.0 Strict which demands valid XML in the first place. This means that considerably more processing is needed to massage the mangled string-representation from "innerHTML" into valid XML. Currently, the major web browsers all return different variations of the underlying document elements when using "innerHTML";Firefox 1.5 fails to close single elements like "img", "br", "input" and so on - while Opera 9.0 returns element namesuppercase d - finallyInternet Explorer fails on both the former as well as omitting the standard required "quotes" around attribute values. In the case of Opera and Firefox it is just one omission each - and hopefully it will get fixed soon. Meanwhile, developers must fix the innerHTML output before processing it further.Another use of innerHTML is relaying it to Flash via
ActionScript and its "ExternalInterface" callingJavascript -functions in the main document. This requires valid XML for parsing, and can be used to avoid loading external content via Flash, but rather include it in the main document structure for replacement or Flash representation. This would also help in SEO-efforts.tandardization
AHAH has been adopted as part of the REST-Enabled XHTML (REX)
microformat . The methods for implementing AHAH have also been made available in Javascript libraries, and also have the advantage of being small in terms of code size.AHAH functionality is also built into the
w3c XForms recommendation standard. XForms uses aModel-view-controller architecture to allow any form events to fetch server XML data into a form instance data with no need for Javascript coding.External links
* [http://microformats.org/wiki/rest/ahah AHAH microformat description, microformats.org]
* [http://www.quirksmode.org/dom/innerhtml.html innerHTML vs DOM-manipulation benchmarks on various browsers, quirksmode.org.]
* [http://www.gizax.it/ahahsection/ AHAH experiments, gizax.it]
Wikimedia Foundation. 2010.