RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


AJAX: A Fresh Look at Web Development : Page 4

AJAX enables a dynamic, asynchronous Web experience without the need for page refreshes. Find out how this combination of technologies that you already know and love can reinvent your Web development.

Step 5: Improving the Robustness of the AJAX Application
Any extensive use of JavaScript inevitably raises concerns about the robustness and reliability of an application that heavily relies on this very relaxed and forgiving scripting language. With AJAX, the issue is even more complicated. AJAX makes remote calls, which introduce an additional dimension of complexity and the opportunity for errors—especially considering that built-in support for server-side error conditions is very limited.

With all this in mind, here are some immediate error-prevention suggestions:

  • Make sure that your application can function in a bare bones mode, even without the AJAX.
  • Verify response codes from the AJAX calls before the further processing of the results.XMLHttpRequest API supports HTTP codes (200, 400, ...). These can be accessed via the status property (along with the statusText property, which holds the message associated with the status of the response):
    if ( httpRequester.readyState == 4) {
    // if the status is 200 (OK) proceed
    if ( httpRequester.status == 200) {
    // ... process results ...
    } else {
    // ... handle or report error here ...

AJAX Implementation: An Art of Tradeoffs

Many programmers consider JavaScript a sub-optimal programming solution because of its lacking debugging methods and its error-prone, weak-typed programming model. With this in mind, it is fair to say that AJAX is a solution of trade-offs. You trade the safety of the more robust languages like Java or C# for the presentational attractiveness and the innovative appeal of this JavaScript-based technology.

Hopefully, the popularity of AJAX and the increasing use of JavaScript will prompt browser producers to further innovate the JavaScript objects and incorporate mechanisms that make JavaScript objects a bit more compatible, safer to use, and easier to debug.

In the meantime, I see AJAX as an immediate candidate for the new generation of Internet portals and interactive applications. With AJAX, Internet news portals such as Yahoo, Google News, or MSN will allow users to access all areas of interest—including specific details—from the same portal page.

The promise of rich clients that can be implemented by leveraging existing Web technologies and Internet infrastructure as-is is attractive. Interactive communication applications already have adopted AJAX—Google uses it for its ultra-popular Gmail e-mail client—and I expect this trend to continue.

One advantage that software development teams will enjoy is this technology's accessibility and flat learning curve. As previously mentioned, it is available on all modern browsers. Also, it does not require advanced programming skills like J2EE or .NET, yet it can produce impressive and effective results that will appeal to end users.

Helpful Tools and Extensions

As AJAX grows in popularity, helpful third-party extensions will continue to emerge—ones that make complex tasks such as debugging, cross-browser development, and XML processing easier. Some of the more prominent extensions that you may find helpful today are:
  • Greasemonkey
    Greasemonkey is a Firefox extension that enables installation of custom DHTML scripts. Some blog authors (see resources) have produced scripts that help trace and debug AJAX routines utilizing Greasemonkey features.
  • Sarrisa
    Sarrisa is a script library that automates and simplifies the most common XML operations (e.g., XML document loading from URL, instantiations, XPath, XSLT processing) with AJAX, as well as cross-browser implementations and testing.
  • Direct Web Remoting (DWR)
    DWR is an AJAX-based Java remoting library that enables asynchronous remote invocation of Java server code from the JavaScript routines.

Edmon Begoli a software architect with 14 years of professional experience on large commercial and federal software projects. He is a member of the R&D staff at Oak Ridge National Laboratory.
Email AuthorEmail Author
Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date