Prototype - AJAX Request() Method

This AJAX method initiates and processes an AJAX request. This object is a general-purpose AJAX requester: it handles the life-cycle of the request, handles the boilerplate, and lets you plug in callback functions for your custom needs.

In the optional options hash, you can use any callback function like onComplete and/or onSuccess depending on your custom needs.

Syntax

new Ajax.Request(url[, options]);

As soon as the object is created, it initiates the request, then goes on processing it throughout its life-cyle. The defined life-cycle is as follows −

Created

Initialized

Request sent

Response being received (can occur many times, as packets come in)

Response received, request complete

There is a set of callback functions, defined in Ajax Options,, which are triggered in the following order −

Portability

Depending on how your browser implements XMLHttpRequest, one or more callbacks may never be invoked. In particular, onLoaded and onInteractive are not a 100% safe bet so far. However, the global onCreate, onUninitialized and the two final steps are very much guaranteed.

Return Value

new Ajax.Request

Disabling and Enabling a PeriodicalUpdater

You can pull the brake on a running PeriodicalUpdater by simply calling its stop method. If you wish to re-enable it later, just call its start method. Both take no argument.