h2. Overview

[[ajax]] makes WebApplications seem much more responsive, and may seem like magic at first, but it is really quite simple in principle.

Using AJAX, only small parts of a page are updated in response to the users actions. This contrasts with the traditional approach which reloads a whole new page everytime any change is needed. The AJAX approach results in a more responsive experience for the user, but as it depends on more sophisticated technology, it cannot be used in all cases.

Normally (in a non-[[ajax]] WebApplication) every action the user takes results in an [[HTTP]] request being sent to the server, to which the server responds with an whole new page for the browser to render.

This process can be time consuming, and is often largely unnessesary, especially if only a small part of the whole page needs updating. Further, having to wait for the server to complete request-response cycle (see UnderstandingWebApplications) before being able to interact with the page is needlessly unpleasant for the user.

Various methods have been developed to deal with this issue:

* Using JavaScript to handle actions ClientSide where possible.
* Using frames so that only part of the page needs to be refreshed
* Using StyleSheets to seperate the data from the formatting information (since actions frequently change either the content or the format but not the other)

[[ajax]] is simply the culmination of this trend, with some added polish.  A typical [[ajax]] set-up uses [[XML]] to transfer data (thus providing even more separation than HTML vs. CSS) and updates the [[DOM]] at a much finer granularity than is possible with frames.  It allows the user to continue working (the first "a" is "asyncronous").

In rails, this is all handled by a JavaScript package known as the [[Prototype|Prototype library]]. This is included with the standard Ruby on Rails distribution.

O'Reilly has posted a tutorial for using Ajax with Rails, entitled "Ajax on Rails":http://www.onlamp.com/pub/a/onlamp/2005/06/09/rails_ajax.html .

h2. Capturing actions

h2. Requesting XML

h2. Updating the DOM

Category: Understanding
