Question: I can't seem to be able to set this.chkOK inside my ajax function. I'm sorta clueless how I go about doing this so I thought maybe calling validateFields.call(this) should of fixed my problem but I found out that wasn't the case. So I'm sorta lost what to do for my next step. I don't want to set this to a global variable unless I have to. I'm trying to set this.chkOK = true

```
function validateFields() {

this.chkOK = null;

this.username = function() {
    if(FS.gID('username').value.length >= 2) {

        var user = FS.gID('username').value;

        //Make sure that the username doesn't already exist
        FS.ajax('/server/chkUser.php?user='+user,'GET',function(){
            validateFields.call(this);
            if(xmlText == 0) {

                    this.chkOK = true;
                alert("This user doesn't exist.");

            }
            else if(xmlText == 1) {
                alert("Theres already a user with this username");
                this.chkOK = false;

            }
        });

    }
    else {
        alert("empty");
        this.chkOK = false;
    }
alert(this.chkOK);

}
 }

```

Answer: 
The value of `this` in your example is NOT the function inside which it's declared, like you assume in your code. 

If you simply use `var chkOK = null;` instead of `this.chkOK = null;` it should start to work.
It is because this inside the FS.ajax is not the same with this you intended to work with. `this` in FS.ajax means this of FS

You may assign this into another variable and use it inside FS.ajax. For example,

> 
> ***Note***: Unless you know the reason why you put `this.chkOk` inside the function (such as expected validateFields be invoked by `call` or
>  `apply`) `this` is global object (which you don't want to) or
>  `undefined` in strict mode which will cause the code to fail
> 
> 
> 

```
function validateFields() {

    this.chkOK = null;

    // ** assign this to that. So you can reference it inside FS.ajax **
    var that = this;

    this.username = function() {
        if(FS.gID('username').value.length >= 2) {
            var user = FS.gID('username').value;

            //Make sure that the username doesn't already exist
            FS.ajax('/server/chkUser.php?user='+user,'GET',function(){
                validateFields.call(this);
                if(xmlText == 0) {
                    that.chkOK = true; // use `that` instead of `this`. 
                    alert("This user doesn't exist.");
                } else if(xmlText == 1) {
                    alert("Theres already a user with this username");
                    that.chkOK = false; // use `that` instead of `this`
                }
            });
        } else {
            alert("empty");
            this.chkOK = false;
        }

        alert(this.chkOK);
    }
}

```