Introduction
Asynchronous JavaScript and XML (AJAX) are new ways to build rich Web applications using native browser technology. JavaScript has done a good job for developers who write complex applications that require certain types of "active" user interfaces. However, JavaScript is difficult to encode, debug, migrate, and maintain. Using AJAX toolkits helps minimize many of the common problems with JavaScript and Ajax. The excellent AJAX Toolkit provides a reusable set of widgets, frameworks for extending and creating widgets, event systems, JavaScript utilities, and enhanced asynchronous server invocation support. In this article, we'll discuss how to use the Dojo Toolkit to build Enterprise SOA clients for Java EE applications. We will also use the JSON (JavaScript object notation) –rpc to invoke the server-side Java object.
In this article, we will also provide you with a brief description of Ajax, Dojo, JSON, and JSON-RPC, as well as some design principles for designing AJAX applications and brief examples that you can download and try to run yourself.
Ajax Overview
There are lots of papers, articles and books about Ajax. I'm not going to go into Ajax for an in-depth introduction. For more information, see Resources.
Ajax can be used as an architectural style for building Web sites using native browser components. The key parts of Ajax are:
JavaScript, which can orchestrate page elements to get the best Ajax user experience.
Cascading style Sheets (CSS), which defines the visual style of a page element.
Document Object Model (MODEL,DOM), which provides a web page structure as a set of programmable objects that can use JavaScript operations.
XMLHttpRequest, which supports retrieving data from Web resources in the form of background activity.
The XMLHttpRequest object is a critical part.
XMLHttpRequest objects
The XMLHttpRequest object is the mechanism by which Ajax is used for asynchronous requests. Figure 1 illustrates this process:
Figure 1. Flowchart for asynchronous requests by XMLHttpRequest objects