I have a form submit handler that needs to make an AJAX call before the "default" form submit occurs.
$('#form').on('submit', function (event) {
{ ... }
$.ajax({
type: "POST",
data: data,
url: "/submit"
}).done(function() {
{ ... }
// Do default form action here
return true;
});
});
The code above the ajax call runs, but as soon as the ajax call is made the form is submitted and I'm redirected to the action URL.
How can I prevent the default form submit from occurring until the after the AJAX callback is called?