I am using the jQuery UI tabs where each tab has a different form on it. After the user enters various pieces of data, they submit the entire set of tabs so that each tab posts to the server asynchronously. This works well, and I have no problems here.
However, where I run into a problem is that, the last form that I post has to happen AFTER all the other posts complete. General idea is like this:
postForm(0, "#Form1");
postForm(1, "#Form2");
postForm(2, "#Form3");
postForm(3, "#Form4");
$.post('Project/SaveProject', function (data) {
$('<div class="save-alert">The current project has been saved.</div>')
.insertAfter($('#tabs'))
.fadeIn('slow')
.animate({ opacity: 1.0 }, 3000)
.fadeOut('slow', function () {
$(this).remove();
});
});
The postForm function does a little bit of processing and then makes an AJAX $.post call. The last $.post performed here (to 'Project/SaveProject') must wait until those other posts are completed. What is the best way to go about doing that?