0

这是代码(已经导入了 JQuery):

$.post("check.php", { username: usr },
    function(result)
    {
        //if the result is 1
        if(result == 1)
        {
            //show that the username is available
            $('#ck_usr_rslt').html(username + ' is Available');
        }
        else
        {
            //show that the username is NOT available
            $('#chk_usr_rslt').html(username + ' is not Available');
        }
});

问题是,我的 check.php 脚本不断抛出以下错误:

PHP Notice:  Undefined index: username in /Applications/MAMP/htdocs/RP/check.php on line 23

(第 23 行是调用 $_POST['username'] 的时间)

那么有什么问题呢?可能是我正在运行的本地服务器有问题吗?还是只是我在 JavaScript 中的一些错误?

4

1 回答 1

0

似乎“usr”变量是空的(它是一个javascript而不是php),你能告诉我们如何检索那个变量吗?

于 2012-08-05T19:44:39.943 回答