Java Reference
In-Depth Information
mouseover: handleEvent,
mouseout: handleEvent,
click: handleEvent
});
});
However, there's no real need to do so in this example. But this would be the best way if you needed to
perform other processes on each element. That way, you iterate over the elements once as opposed to
multiple times.
ajax support in mootools
MooTools has three objects for making HTTP requests, each targeting a specific purpose:
➤
Request
: Used for general requests
➤
Request.HTML
: Used specifically for receiving HTML
➤
Request.JSON
: Specifically used for receiving JSON
Each of these objects is similar to Prototype's
Ajax.Request
, in that you directly create them by
calling their constructor functions with the
new
operator and passing an object that contains various
options:
var request = new Request({
method: "get",
url: "someFile.txt",
onSuccess: requestSuccess
});
This code creates a
Request
object that makes a GET request for
someFile.txt
and calls the
requestSuccess()
function on a successful request.
You can pass many more options to the constructor; the following table lists some of them.
option
desCription
Determines whether or not the
XMLHttpRequest
object makes the request in
asynchronous mode. The default is
true
.
async
An object containing the key/value pairs to send with the request
data
The HTTP method used for the request. The default is
"post"
.
method
A callback function invoked when the request completes successfully
onSuccess
A callback function invoked when the request completes, but results in an error
status code
onFailure
The URL to send the request to
url