使用jQuery使用ajax检查用户名可用性

时间:2011-10-04 13:07:47

标签: jquery

我尝试使用下一个示例来检查用户名可用性,但我无法收到我想要的.post结果。

http://web.enavu.com/tutorials/checking-username-availability-with-ajax-using-jquery/

在下一个代码中,alert()显示.php文件,但我只想要0或1以便知道用户是否存在:

    //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');
            }
    });

非常感谢!

1 个答案:

答案 0 :(得分:1)

你在哪里托管你的php文件?在apache里面?如果您正在获取php文件的全部内容,那么很可能您没有正确部署它。