Java Reference
In-Depth Information
With MooTools, you simply use the dollar function to retrieve the element and use the value property.
The next change is at the end of the function when you make the request. First, you use the
getBasicOptions() function to return an options object with the predefi ned options you want to
use for the request. Then you add the onSuccess option and assign it a pointer to the checkUsername_
callback() function.
var options = getBasicOptions();
options.onSuccess = checkUsername_callBack;
You then make the request by creating a new Request object with its constructor, passing it the
options object, and sending the request with the username parameter.
new Request(options).send(“username=” + userValue);
On a successful request, the checkUsername_callback() function is called. The fi rst change you
made to this function is the parameters. MooTools passes the XMLHttpRequest 's responseText and
responseXML properties, respectively, to the Request object's callback functions.
function checkUsername_callBack(text, xml)
Here they are simply called text and xml. Next, you retrieve the text in the Username text box again,
using the dollar function and the value property.
var userValue = $(“username”).value;
The fi nal change of this function is the condition of the if statement.
if (text == “available”)
Compare the value of the text parameter with the string “available”, and display a message to the
user either stating that the user name is or isn't available.
The checkEmail() and checkEmail_callback() functions underwent the same changes as
checkUsername() and checkUsername_callback() . Again, you'll focus only on the changes
made to these functions starting with checkEmail() .
The fi rst change to this function is the retrieval of the Email text box:
var emailValue = $(“email”).value;
Use the dollar function, pass it the id of the <input/> element, and use the value property to retrieve
the text. The next change is making the request, but before you can make the request, you must create
the options object, populate it with the basic settings, and add the onSuccess option.
var options = getBasicOptions();
options.onSuccess = checkEmail_callBack;
Now that all options are set, simply call the Request constructor, pass it the options object, and send
the email parameter and its value to the server.
new Request(options).send(“email=” + emailValue);
On a successful request, the Request object calls checkEmail_callback() and passes it the
XMLHttpRequest object's reponseText and responseXML properties.
function checkEmail_callBack(text, xml)
Search WWH ::




Custom Search