Let’s say you want to do an asynchronous request just before saving a Sharepoint form, but after Sharepoint verified all the fields in your form (for mandatory ones, or for format, …). Here is my solution to do it (using jQuery.Deferred):

// this function will do our asynchronous check
function beforeSaving() {
var deferred=jQuery.Deferred();
setTimeout(function() {
alert("Test Complete!")
deferred.reject(); // if the test failed
// or deferred.resolve() to valid the test
}, 2000)
return deferred;
}
// force PostBackRequired to true in the context, otherwise it won't work if you open it into a modal
WPQ2FormCtx.PostBackRequired=true;
// we override SPClientForms.ClientFormManager.SubmitClientForm
SPClientForms.ClientFormManager.SubmitClientForm=function(b){
var a=SPClientForms.ClientFormManager.GetClientForm(b);
var res = (a!=null&&a.SubmitClientForm());
// if the form is not valid, then res===true
if (res === true) return true;
else {
// if the form is valid we now want to do our asynchronous check
beforeSaving().done(function() {
// our test is valid too so we can send the form to the server
WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions($get(WPQ2FormCtx.SubmitButtonID).name, "", true, "", "", false, true))
}).fail(function() {
// if it fails we just unblock the save button
$get(WPQ2FormCtx.SubmitButtonID).disabled=false;
})
}
// to make sure the form won't be submitted yet
return true;
};