var $button = $('button');
$('body').on('submit', 'form', function(e) {
e.preventDefault();
$button.addClass('is-busy');
var formData = !!window.FormData ? new FormData($(this)[0]) : $(this).serialize();
$.ajax({
url: '/request/url',
type: 'POST',
data: formData,
dataType: 'JSON',
contentType: false,
processData: false,
success: function(response) {
$button.removeClass('is-busy');
},
error: function(response) {
$button.removeClass('is-busy');
}
});
});