1. Home
  2. Computing & Technology
  3. JavaScript
photo of Stephen Chapman
Stephen's JavaScript Blog

By Stephen Chapman, About.com Guide to JavaScript since 2004

Asynchronous Javascript and XML

Sunday June 19, 2005
One of the biggest limitations on using a client side language like javascript has always been that there was no easy way of interacting with the server without having to reload the whole web page. This problem has been rectified by recent browsers which have gradually implemented ways for Javascript to request information from the server and have that information passed back without having to reload the entire page. This process is done asynchronously (which means that the request is passed but the Javascript doesn't wait for the reply but gets on with something else). When the reply does come it triggers some further Javascript to complete the processing. The biggest problem with this has been that the commands to do this are not identical on each browser. This process of sending a request back to the server and retrieving information without having to load a whole new page has now been given a name - AJAX - and there are a number of projects underway to produce classes that hide the different methods that the various browsers use and give you a common set of calls to provide this function.

AJAX like DHTML is not a new technology as such. Rather it is a combination of existing technologies in order to create a new effect. DHTML combined Javascript with HTML and CSS to create dynamic effects for your web page. AJAX combines Javascript with XML and a server side language (eg. PHP) to provide a way for your web page to actually interact with the server without the overhead of downloading a brand new page every time a simple request is made.

One example of where this could be useful is if you have a new user selecting a logon id. Using Javascript alone the only validation you can perform is to verify that the logon id meets the minimum and maximum lengths that you accept and does not contain any invalid characters. To validate that the selected logon id is not already in use by someone else you need to check the database to see if the id already exists. Javascript by itself can't do this but by using AJAX the Javascript can pass the requested logon id back to the server for checking and receive a reply that can be dynamically displayed on the page (again through Javascript) without having to wait for the form to be submitted and a whole new web page to load.

There are a number of web sites that have information on AJAX and books that mention the subject are just starting to appear in the bookshops.
Comments

No comments yet. Leave a Comment

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

Explore JavaScript
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. JavaScript

©2009 About.com, a part of The New York Times Company.

All rights reserved.