Java Reference
In-Depth Information
Note Visit http://mootools.net/core/docs/1.5.1/Request/Request fo r a
complete list of options and callback functions.
Unfortunately, creating a Request object doesn't automatically send the request; you must explicitly
send it with the send() method:
request.send();
But to save some typing, you can chain the send() method to the Request constructor, like this:
var request = new Request({
method: "get",
url: "someFile.txt",
onSuccess: requestSuccess
}).send();
You can also use one of the many aliases for send() . Their names mirror those of the different
HTTP methods, and they send the request with the given method. For example, the get() method
sends a GET request, post() sends POST, put() is a PUT request, and so on. Using an alias
eliminates the need to specify the method option. For example:
var request = new Request({
url: "someFile.txt",
onSuccess: requestSuccess
});
 
request.get(); // sends the request as GET
request.post(); // sends as POST
You can send data with your request in two different ways. First, you can make it part of the
Request object. This is useful if you need to send the same data with every request you make with
a single Request object. To do this, you add a data property to the options object you pass to the
constructor. An example of this is:
var request = new Request({
url: "ch14_formvalidator.php",
data: {
username: userValue // assuming userValue is assigned a value
},
onSuccess: requestSuccess
});
The second approach decouples the data from the Request object so that you can reuse the same
Request object for sending different data. To use this approach, you pass the data to the send() , or
other alias, method like this:
var request = new Request({
url: "ch14_formvalidator.php",
onSuccess: requestSuccess
Search WWH ::




Custom Search