I am doing an AJAX call in my beforeSubmit() function, as follows:
$('#register-form').on('beforeSubmit', function(event) {
    $.ajax({
        url: url,
        success: function(response) {
            return response.status; // boolean
        }
    });
});
I want the result of the AJAX success function (true or false) to determine the return value of the beforeSubmit() function.
I realise that you can't return within ajax success, I'm also aware a potential solution to this would be to set async: false in my AJAX call, however I know this isn't recommended, so would prefer to try a different solution.
I have tried to implement a "callback" function as detailed in these posts:
ajax return true/false - I have implemented a callback
jQuery: Return data after ajax call success
But I still cannot seem to get it to work.
