Java Reference
In-Depth Information
You create a handlers object, and create its properties to have the same names as the events you
want to handle. Assign these properties a pointer to the handleEvent() function, and then pass the
handlers object to the addEvents() method of the document object.
Ajax Support in MooTools
The Ajax utilities of MooTools are quite different from jQuery and somewhat different from Prototype.
The MooTools Ajax utility revolves around the Request reference type. Like Prototype's Ajax.Request,
you create an instance of Request, and pass it an object that contains a set of options. The following
table lists some of these options.
Option
Description
async
Determines whether the XMLHttpRequest object makes the request in asyn-
chronous mode or not. The default is true .
method
The HTTP method used for the request. The default is “post” . “get” is
another valid value.
onSuccess
A callback function invoked when the request completes successfully.
onFailure
A callback function invoked when the request completes, but results in an error
status code.
url
The URL to send the request to.
Visit http://mootools.net/docs/core/Request/Request for a complete list of options and
callback functions.
All callback functions are executed and passed varying parameters. The onSuccess callback func-
tion is passed two parameters, the fi rst being the XMLHttpRequest object's responseText and the
second being the responseXML. The onFailure callback is simply passed the XMLHttpRequest object.
Making a request using the Request reference type looks something like the following code:
function request_onsuccess(text, xml)
{
alert(text);
}
function request_onfailure(request)
{
alert(“An error occurred! HTTP status code is “ + request.status);
}
var options = new Object();
options.method = “get”;
options.onSuccess = request_onsuccess;
Search WWH ::




Custom Search