开发者

Check username using AJAX

开发者 https://www.devze.com 2023-02-24 23:01 出处:网络
I am having problems with validation using AJAX. I want to check if a given username exists. Here is my relevant code:

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

精彩评论

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