I've created a javascript function that calls on a php page to return either a 1 or a 0. The return is always coming back as undefined.
$(document).ready(function(){
if($('#username').val()!=""){
alert(checkfees($('#username').val())); //returns undefined
if(checkfees($('#username').val())){
alert("has fees");
}
else{
alert("no fees");
}
}
});
function checkfees(username){
$.post( "checkfees.php", { uname: username }).done(function(data) {
if(data=="1"){
return true;
}
else{
return false;
}
});
}
The function appears to work. The variable "data" has the correct information (either a 1 or 0), so the correct if statement is hit inside the checkfees function, but the return keeps coming back as undefined.