An Ajax Library
Through the lessons and code examples up to now, we have developed a number of JavaScript code techniques for implementing the various parts of an Ajax application. Among these methods are:
A method for generating an instance of the XMLHTTPRequest object, which works across the range of currently popular browsers
Routines for building and sending GET and POST requests via the XMLHTTPRequest object
Techniques for avoiding unwanted caching of GET requests
A style of callback function that checks for correct completion of the XMLHTTPRequest call prior to carrying out your wishes
Methods of providing user feedback
Techniques for dealing with text data returned in responseText
Techniques for dealing with XML information returned in responseXML
In addition, you saw in Lesson 13, "AHAHAsynchronous HTML and HTTP," how some of these methods could be abstracted into a small JavaScript "library" (in that case containing only two functions).
This lesson extends that idea to build a more fully featured library that allows Ajax facilities to be added simply to an HTML page with minimal additional code.
Of necessity, our Ajax library will not be as complex or comprehensive as the open source projects described later in the book; however, it will be complete enough to use in the construction of functional Ajax applications.