Request (aka Ajax)

Here is the documentation for Request.js.

The Request class is a relatively simple wrapper for the XMLHttpRequest object (the heart of Ajax functionality).

It takes the following options:

The URL to request (defaults to //null//; you can use the //send// method to specify the url later).
The HTTP method for the request, can be either 'post' (the default) or 'get'.
The default data for Request:send, used when no data is given. Defaults to ''.
If set to //false//, the requests will be synchronous and freeze the browser during request. Defaults to //true//.
The encoding to be set in the request header. Defaults to "utf-8".
When set to //true//, automatically cancels the already running request if another one is sent. Otherwise, ignores any new calls while a request is in progress. Defaults to //false//.
An object to use in order to set the request headers.
Provide a function to override the built-in isSuccess function.

Then you'll need to call the .send method to actually initiate a request. .send takes two arguments, the url, and the data to send.

new Request({method: 'get'}).send('');


MooTools has a "built-in" instance of Request that you can use to send a form with an ajax post request.

<form id="myForm" action="submit.php">
	<input name="name" value="bob">
	<input name="zipCode" value="90210">
$('myForm').send({onComplete: handleMyResponse})

You can use set to alter the options of the "built-in" version of Request:

$('myForm').set('send', {
	method: 'get'

mootorial/07-request/00-request.txt · Last modified: 2010/03/04 15:01 by aaron-n