Building an AJAX engine or an AJAX framework that you can reuse every time you want some asynchronous processing or when you need a smart way to refresh information on the current web page will help a lot.
If you realize a web application with only containing one or a only a few Web services you can stay with the kind of realization that is shown in the preceding examples.
The main idea of an AJAX engine on the client is the simplification of the implementation of the code, which is needed for a specific function on the Client. Like with the webservice framework of ASP.NET on the server the details of communication over SOAP on the client are completely hidden from the developer and also the recurring code portion is only realized once in a central place. Also all details about the different implementations of the XMLHTTP object in Internet Explorer or the Firefox browsers are hidden from your code.
The blue print of the AJAX engine has the following connected components:
HTML form and elementsThe static or dynamically provided HTML of objects e.g. < input > elements become for the interaction with the user used.
Buttons & Events
For the call of a server-side functionality parameters must be retrieved and the result must be processed on the Client. These elements together form a AJAX action.
Web methods and proxies
The proxy framework is used on the client to call the server-side methods.
The execution of the individual steps of an AJAX functionality using a timer and XMLHTTP objects is coordinated and supervised by the AJAX engine. The methods for the implementation of the AJAX engines are available in ajax.js.
Also the AJAX engine needs only one variable with the name Ajax to be declared in the global namespace to minimize name conflicts.
In many cases it is importantly for the implementation of actions that they occur one after the other by using a queue mechanism. This is also necessary from a network perspective because with HTTP connections only 2 simultaneous requests per server should be made at a time.
Therefore the AJAX engine implements a queue. Using some attributes on the AJAX actions it is possible to control the way how the existing entries are treated when starting of a new action.
There are several examples of AJAX actions are published on my Website at http://www.mathertel.de/AJAXEngine/.