Creating the Engine






Creating the Engine

In Chapter 2, "The Request," we created a few functions to create an XHR, and handle receiving and displaying a response. This solution works fine in many cases, especially for simple Ajax-based web pages, but it is not the best solution for large web applications. In order to manage multiple requests and delegate responses to specific requesting objects, we will create an Ajax engine. This engine will consist of two objects: Ajax and AjaxUpdater. The AjaxUpdater will manage all requests and delegate them to the Ajax object. The Ajax object will receive the requests from the AjaxUpdater and instantiate an XHR object. After the XHR object has been instantiated and the requesting object receives a response, the requestor can then call two more methods within the Ajax object. The first method checks the ready state of the request and the second returns the request object in its completed form. We will cover these methods in more detail throughout this chapter. Let's start by creating the Ajax wrapper, which we will later be able to reuse to manage large Ajax applications.



 Python   SQL   Java   php   Perl 
 game development   web development   internet   *nix   graphics   hardware 
 telecommunications   C++ 
 Flash   Active Directory   Windows