
o you want to jump into the AJAX (asynchronous JavaScript and XML) development fray, but you don't want to make the
XMLHttpRequest calls directly by writing the
XMLHttpRequest code yourself. Then you've no doubt noticed the new, freely available AJAX libraries that seem to appear every day and the plethora of commercial AJAX products seeking to make you fully buzzword compliant. All of them seem to abstract you from hand coding (although those developers who want to know every line of code their applications execute may prefer that), but how do you go about choosing the right one?
The first step is understanding the two basic types of library and the paths they each take to get AJAX functionality into your application:
- Pure JavaScript libraries provide core remote scripting.
- Server-based AJAX libraries generate the AJAX code from your server application.
Each type has its place depending on the type of application you're developing, but mixing and matching the two is an option also. In the end though, your personal preference plays the largest role in your choice (see Table 1. Pros and Cons of AJAX Library Types). To help you determine which is right for you, this article highlights the strengths and weaknesses of three popular pure JavaScript libraries and a few options offered by the server-based AJAX libraries for ASP.NET, PHP, and Java.
| AJAX Library Type |
Pros |
Cons |
| Server Based |
Can map native server objects such as database results to JavaScript equivalentsMinimizes the amount of JavaScript code you have to handle (depending on the library) |
Ties the JavaScript code tightly to the server language |
| Pure JavaScript |
Capable of handling multiple server languagesClearer separation of client and server code |
Leaves you to manage how to translate your server-side return values to XML or JSON |
| Table 1. Pros and Cons of AJAX Library Types |