AJAX - The Complete Reference

(avery) #1

114 Part I: Core Ideas


Summary


The XMLHttpRequest object is the heart of most Ajax applications. This useful object
provides a general purpose facility for JavaScript to make HTTP requests and read the
responses. It does not force the use of XML as payload, as we will discuss greatly in the next
chapter, though it does provide some conveniences for dealing with XML in the form of the
responseXML property, which will automatically parse any received XML data.
The syntax of the XHR object is somewhat of an industry de facto standard at the moment,
with browser vendors implementing the core syntax introduced initially by Microsoft. For
basic usage, the browser vendors are pretty consistent in their support; however, in the details,
there is quite a bit of variation across browsers in areas such as XHR object instantiation,
header management, ready states, status codes, extended HTTP methods, authentication, and
error management. Browser vendors have also already begun to introduce proprietary
features, some of which are quite useful, but sadly not widely supported.
Based upon the various quirks and inconsistencies presented at the point of this book’s
writing in 2007, readers are duly warned that they should not take the details of XHRs for
granted and should be cautious with any Ajax communication library they may adopt.
Fortunately, the W3C has begun the standardization process which should eventually bring
some much needed stability and polish to the XHR syntax.
Free download pdf