i am trying to run some jquery code before submitting form so when user hits submit function a function is executed where i send a post request to server to check if user already exist. in post request response is coming but in my code it always says undefined
This is my code on submit
      $('#addmember').submit(function() {
        phone = $('#phone').val();
        password = $('#password').val();
        password_confirmation = $('#password_confirmation').val();
        if (phone.length != 10) {
            alert('Please enter a valid mobile number');
            return false;
        }
        if (password.length < 6) {
            alert('Minimum password length is 6');
            return false;
        }
        if (password != password_confirmation) {
            alert('Confirm password is not matching');
            return false;
        }
        check = checkExist(phone);
        if(check != 0 ) {
            alert('Mobile Number is already registered please use some other number!');
            return false;
        }
    });
function checkExist(phone) {
     $.post("{{url('user/check')}}", {
            "_token": $('meta[name="csrf-token"]').attr('content'),
            phone: phone
        },
        function(data, status) {
           return data;
        });
}
when i run this check variable is always undefined
