这是代码(已经导入了 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 中的一些错误?