I want to use $.when() to execute code after several Ajax.BeginForm forms on the page have completed submission. Each of the forms can be submitted like so:
$('#formA').submit();
$('#formB').submit();
After reading this answer, I attempted the following:
$.when($('#formA').submit(), $('#formB').submit()).done(function(a1, a2)
{
alert('Finished!');
}
Unfortunately this does not work - all forms return immediately and the "Finished!" dialogue box appears right away even though the ajax requests are still processing. I know they're not finished processing b/c at this point none have made a callback to their AjaxOptions' onComplete function. The example linked above uses an
return $.ajax({ });
block to designate the promise that the $.when() should wait for. Presumably this is why my code does not work - as far as I know, I am not able to mandate a return on the Ajax.BeginForm element.
Does anyone have a suggestion for how I can use $.when() in conjunction with multiple Ajax.BeginForm asynchronous requests?
Thanks in advance!