$(document). on('click', "#report-issue-submit", function(e){ $(this).html('Sending'); $(this).attr('disabled', true); var $cancelButton = $('#report-issue-cancel'); if ($cancelButton) { $cancelButton.html('Close'); } $('div').remove('.modal-footer-status'); $.ajax('/'). success(function(data, status, jqxhr) { var $sendButton = $('#report-issue-submit'); $sendButton.html('Report sent'); $('div').remove('.modal-footer-status'); $('.modal-footer').append('

'); }). fail(function(jqxhr, status, error) { var $sendButton = $('#report-issue-submit'); if ($sendButton && $sendButton.prop('disabled')) { $('div').remove('.modal-footer-status'); $('.modal-footer').append('

'); $sendButton.html('Send problem report'); $sendButton.attr('disabled',false); } var $cancelButton = $('#report-issue-cancel'); $cancelButton.html('Cancel'); }); });