I'm trying to perform some AJAX validation in a submit() handler for a web form. The ajax is being performed with $.ajax() from jquery. If I use async: false it works great but I get a deprecation notice and I'd just assume have code that's future proof.
So my question is how can I perform AJAX validation without async: false?
https://stackoverflow.com/a/9865124/569976 recommends the when() function. idk how I can use that for my purposes. I suppose I could have that set a global variable complete to true in the done() part of the when() method but how do I know when complete is set to true? I suppose I could do setInterval to keep on checking the value of complete until it's finally true and could then use JS to submit the form but idk that seems inelegant.
https://stackoverflow.com/a/14038050/569976 mentions $.ajaxStop but I gather that's not best practices.
I also tried this (in the $('...').submit(...) method):
await Promise.all(function() {
    return $.ajax(...);
})
That got me a Uncaught SyntaxError: await is only valid in async function error.
Any ideas?
 
    