(function($){ $(document).ready(function() { const form = $('#fess'); const btn = $('#fessbtn'); const options = { url:fess_ajax.url, data: { action:'created_event', nonce: 'fess_ajax.nonce' }, type: 'POST', dataType: 'json', beforeSubmit: function(arr, $form, options){ btn.text('Отправка...'); }, success: function(response){ if(response.data.response == 'ERROR'){ btn.text('Добавить сайт'); $('.fessresp').empty().append(response.data.message).removeClass('alert alert-danger').addClass('alert alert-danger'); } else { $('#form-message').empty(); btn.text('Добавить сайт'); alert(response.data.message); location.reload(); } }, error: function(error){ alert('К сожалению, информацию отправить не удалось'); } }; form.ajaxForm(options); }); })(jQuery);