AHAH
From Wikipedia, the free encyclopedia
This article does not cite any references or sources. Please help improve this article by adding citations to reliable sources (ideally, using inline citations). Unsourced material may be challenged and removed. (July 2008) |
Asynchronous HTML and HTTP, or AHAH, is a method for updating webpages dynamically using Javascript, 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 valid XHTML/HTML structure. It is also known as the microformat rest/ahah.
Contents |
[edit] 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 as XML using the Document 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 major web browsers (or user agents), and was first introduced in Microsoft's Internet Explorer.
[edit] Considerations
AHAH is designed to streamline the case where XMLHttpResponse data obtained from the server does not need to be manipulated in JavaScript before it is injected into the DOM (often using the innerHTML property of an element existing in the target DOM). Proponents of AHAH cite speed as a primary benefit for using this method. Appending to the innerHTML property is faster than parsing the results into a JavaScript-accessible DOM tree[citation needed].
If the data returned from the server must be manipulated by the JavaScript before insertion into the DOM, other approaches (such as parsing the data into its own DOM tree) may be more appropriate. This approach (usually called Ajax) is preferable since the DOM API provides tools for manipulating and traversing (X)HTML and XML content.
Firefox 1.5 will only allow valid element structure being set with innerHTML, while Firefox 2, Opera 8.54 and Internet Explorer 6 & 7 will currently allow any string.
[edit] Standardization
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 a Model-view-controller architecture to allow any form events to fetch server XML data into a form instance data with no need for Javascript coding.