# Mootools return from Ajax class

**URL:** <https://forum.kirupa.com/t/mootools-return-from-ajax-class/251309>\
**Category:** web dev\
**Created:** [February 7, 2008, 5:33am UTC](https://forum.kirupa.com/t/mootools-return-from-ajax-class/251309 "2008-02-07T05:33:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![JoshuaJonah](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/joshuajonah/32/1775_2.png) [@JoshuaJonah](https://forum.kirupa.com/u/JoshuaJonah)\
**Post date:** [February 7, 2008, 5:33am UTC](https://forum.kirupa.com/t/mootools-return-from-ajax-class/251309/1 "2008-02-07T05:33:19Z")

</div>

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:

```auto

       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?
