It's probably easiest to use the jQuery Form plugin to achieve most of this functionality if you had a form that looks like:-
<%= Ajax.Form(new AjaxOptions {
Url = theUrl,
Method = theMethod,
Confirm = confirmFunction,
InsertionMode = InsertionMode.Before,
OnBegin = onBegin,
OnComplete = onComplete,
OnFailure = onFailure,
OnSuccess = onSuccess,
UpdateTargetId = elementId,
LoadingElementId = loadingElementId
});
This would correspond to a form plug-in call of:-
$("#yourFormId").ajaxForm({
url : theUrl,
type : theMethod,
beforeSubmit : confirmFunction,
beforeSend : onBegin,
complete : onComplete,
success : onSuccess,
error : onFailure
});
The only issues are replicating the LoadingElementId, UpdateTargetId and InsertionMode properties.
If you want to replicate InsertionMode.Replace you can pass the additional target option to the ajaxForm plug-in. If you want to replicate the remaining functionality you'd have to write your own beforeSend, success and complete event handlers.
Something like the following would simulate a form with InsertionMode.Before, UpdateTargetId = "Test", LoadingElementId = "Loader":-
$("#yourFormId").ajaxForm({
beforeSend : function() { $("#Loader").show(); },
complete : function() { $("#Loader").hide(); },
success: function(result) { $(result).prependTo("#Test"); }
});