PHP Code:
    //...

    
if(sql_num_rows($result,$dbi)>0){
        
$data['username'] = "Taken";
        
    } else {
        
$data['username'] = "Free";
        
    }
    
header("Content-Type: application/json");
    echo 
json_encode($data);  
    exit;

   
//.... 
See if this helps.