因此,我正在使用 Jquery 后包装器从我的页面运行脚本,并且在 chrome 调试器中发生以下情况:-
1) if the username is taken i'm getting `"taken"`
2) else it echo's nothing.
但是,我无法到达警报('我在这里');行似乎该if(data=="taken")
语句从未运行或始终评估为false,但事实并非如此。我究竟做错了什么?
jQuery
var flag;
$.post('welcome/check_username',{childname: $('#name').val()}, function(data){
if(data=="taken")
{
alert('im here');
return flag = true;
//tell user that the username already exists
}else{
return flag = false;
//username doesn't exist, do what you need to do
}
});
PHP
if ($this->Form_builder->check_unique_username($username, $childname))
{
echo "taken";
}