this code doesn't work, because it always return undefined. In my opinion the "success" from the ajax should return, if the result is there.
How to make sure, that the boolean will be returned?
<script>
        $('#sbtn').on("click", function(e) {
                e.preventDefault();
                
                // if user exists, set validated to true
                var validated = checkUser('requestedUser');
                
                
                
                // if the user is validated, submit form
                if(validated) {
                    //alert("Thank You");
                    $('#setup').submit();
                }
        }
        
        function checkUser(user) {
                
                data = {
                    lernsax_email: user
                }
                
                $.ajax({
                  type: "POST",
                  url: "checkuser.php",
                  data: data,
                  success: function(msg){
                        if(msg === "passed") {
                            // php returns "passed", if the user can be found
                            console.log(msg);
                            return true;
                            
                        }   else {
                            console.log(msg);
                            return false;
                        }               
                        
                    },
                  
                });
        }
    
    
</script>
 
    