开发者

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').

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜