Using jQuery when(), I am trying to run multiple Ajax functions on a form submit, wait until they get their responses and when done, finally submit form. My code is:
$('form[name="regForm"]').on('submit', function( e ) {
e.preventDefault();
$.when( function () {
ajaxOne();
ajaxTwo();
ajaxThree();
}
).done(function() {
$('form[name="regForm"]').unbind('submit').submit();
});
});
The form gets submitted but the Ajax functions never trigger. What am I doing wrong? Thanks for any help.
ajaxOneshould return the promise resulting from the call. Please show the code for at least one of those functions.