Checking username availability with ajax using jQuery
I try to use the next example to checking username availability but I can't receive the result of .post that I want.
http://web.enavu.com/tutorials/checking-username-availability-with-ajax-using-jquery/
In the next code, the alert()开发者_如何学编程 show me the .php file, but I just want 0 or 1 in order to know if the user exist or not:
//use ajax to run the check
$.post("check_username.php", { username: username },
function(result){ alert(result);
//if the result is 1
if(result == 1){
//show that the username is available
$('#username_availability_result').html(username + ' is Available');
}else{
//show that the username is NOT available
$('#username_availability_result').html(username + ' is not Available');
}
});
Thanks a lot!
Where are you hosting your php file? Inside apache? If you are getting the full contents of php file then most probably you have not deployed it correctly.
精彩评论