Check username using AJAX
I am having problems with validation using AJAX. I want to check if a given username exists. Here is my relevant code:
$(document).ready(function()
{
$("#uname").blur(function(){
$.post("usernameCheck.php",{user_name:$(this).val()},function(data)
{
if(data=="no"){
$("#checkUsername").html("This username already exists");
}
else{
$("#checkUsername").html("Username is available!");
}
});
});
});
I can't figure out why t开发者_如何学Che message cannot show. I think there might be something wrong within the AJAX validation.
It looks like your Javascript is OK, except for the update part. $(this)
updates what? You need to update a particular tag, like $('#unameAvail')
.
精彩评论