JSFiddle - React, Tailwind, and code Playground
JavaScript
jQuery.fn.submitWithAjax = function(onComplete) {
onComplete = typeof(onComplete) != 'undefined' ? onComplete : null;
return $.ajax({
type: "POST",
data: $(this).serialize(),
context: $(this),
url: $(this).attr('action'),
dataType: "script",
complete: onComplete
});
//return false;
};
jQuery.saveAndArchive = function() {
//jQuery("input[name='archive_pdr']").val('true');
$.when(
$("form.changed").not("#review_form").each(function() {
$(this).submitWithAjax();
})
//$('#prepare_form').submitWithAjax(),
//$('#training_form').submitWithAjax()
)
.done(function(ajaxResult){
alert("All the Ajaxing is done!");
});
}