I'm doing an ajax request with jquery to check whether a username is taken or not in a database and changing text inside a div (in this case a div with id="wnguser"). I am able to get the response from the php script and the text does appear where it should (I echo one of two strings: "username available" or "username unavailable" from the php script). I am not able though to use the response from the php script, the variable data (in this case one of the two strings mentioned above) to make a decision. 
For example the the if() which I marked as //DOES NOT WORK. Can someone tell me how to make the if() work or the correct way to take a decision base on the response of the php script which is one of two strings.
Thank You
<script type="text/javascript">
        $(document).ready(function(){
        $('#username').keyup(function(){
            var user = $('#username').val();
            $.post('checkusername.php', {username: user}, function(data){
            $('#wnguser').html(data);
            //DOES NOT WORK
            if (data === "username available"){
                 execute some code
            }
            });
        });
        });
    </script>
 
     
     
     
     
    