So I'm running a script from my page using the Jquery post wrapper, and in chrome debugger the below cases happening:-
1) if the username is taken i'm getting `"taken"`
2) else it echo's nothing.
However, I cannot get to the alert('im here'); line it seems that if(data=="taken") statement is never run or always evaluating to false, which is not the case. What am I doing wrong?
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";
}