Hi I am learning a bit of ajax and a bit confused. 

It all works but not 100% sure why? I have the script below of how its structured. What I want to know is how the success: function(result) works. In my php I have the echo for 1 or 0 but I would like to include more info in my php ie the correct message. 

My javascript is. 

```
$("#username1").blur(function(){

 var username1 = $('#username1').val();
  $.ajax({
    type: "POST",
    url: "http://localhost/gonnabook/check_username_availability",
    data:  'username1='+ username1,
    success: function(result){
    if(result == 1){
        alert("true");
        }
    else{
        alert("false");
        }
   }
});

```

php is 

```
function check_username_availability(){

        $check_this = $this->input->post('username1');  
        $data = $this->tank_auth->is_username_available($check_this);
        // the above code does all the query and results in the data
        if($data){
              echo 1;
             //ideally I would like to add a message here ie This is not available
        }else{
            echo 0;

        }
 }

```

So far my understanding is the echo 1 in the php is what the success function in the javascript receives. But how would include a message in the php? Can one do it via an array or something and then the result is result.check or something like that?
The main point is what is the correlation of the result in the javascript and echo of the php?