$(document).on('click', '.form-callback button', function () { var self = $(this); if (self.prop('disabled')) return false; self.attr('disabled', true); var form = $('.form-callback'); $.ajax({ url: 'index.php?route=information/contact/send', type: 'post', data: form.find('input, textarea'), dataType: 'json', success: function(json) { form.find('.color__red.typo-tione').remove(); form.find('.input-error').removeClass('input-error'); self.removeAttr('disabled'); if(typeof json.errors != 'undefined' && json.errors != 0){ if(typeof json.errors != 'undefined' && json.errors != '') { for (i in json.errors){ form.find('[name="' + i + '"]').parent().addClass('input-error'); form.find('[name="' + i + '"]').after('' + json.errors[i] + ''); } } } else if(json.errors == 0){ form.find('[name="name"]').val(''); form.find('[name="email"]').val(''); form.find('textarea').val(''); $('#modal-success').modal({ fadeDuration: 250 }); } } }); });