Not sure if there are many Moo geeks/jQueers here, but im one. Not getting an answer so fast on the mootools forums so i figured id post here.
Ok, so im making a little validation function for checking if a username has already be taken:
var userNameCheck;
function checkUsername(username){
function handleResponse(responseText){
var response = Json.evaluate(responseText);
if(response.result == "exists"){
failInput(userNameCheck, {'string':'This username is in use.'})
return true;
}else if(response.result == "avaliable"){
return false;
}
}
userNameCheck = username;
query = "username="+username.getProperty('value');
new Ajax("php/checkUsername.php" , {
method: 'post',
data: query,
evalResponse:false,
onSuccess: return handleResponse,
onFailure: handleResponse
}).request();
}
the part where it says “onSuccess: return handleResponse,”, can i do that?
is there a smarter way to accomplish what i’m trying?