I'm using JavaScript and jQuery to write a handler for my form being submitted. Based on certain conditions, the handler may allow or prevent the form from submitting.
This is straight forward but is made more complex by the fact that the handler needs to make an AJAX call.
The issue is that my handler will return right away with true or false, but I won't get the response from the AJAX call until later. But I need the result from the AJAX call to decide what the return value should be.
Seems like this must surely be a common scenario. Are there best practices for handling this case?