Skip to content
This repository has been archived by the owner on Dec 3, 2019. It is now read-only.

Commit

Permalink
Merge pull request #87 from sul-dlss/show-error-message-when-ajax-fails
Browse files Browse the repository at this point in the history
show an alert on the page if any ajax call throws an exception (usefu…
  • Loading branch information
Gary Geisler authored Jul 11, 2017
2 parents 76f8f0f + 8625139 commit 43d348a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,13 @@ function ajax_loading_done(element) {
}
}

// if there are any ajax errors (e.g. 500 or timeout on the server), show a generic error message so the user
// knows something bad happened, e.g. when a curator is editing metadata, they submit ajax forms
$(document).ajaxError(function myErrorHandler(event, xhr, ajaxOptions, thrownError) {
$('#main-flashes').html('<div class="alert alert-danger"><a class="close" href="#" data-dismiss="alert">x</a><%=I18n.t('revs.errors.unexpected')%></div>');
window.scrollTo(0,0);
});

// if the user clicks cancel on a confirm box, we need to hide the ajax loader
$(document).on('confirm:complete', function(e,answer) {
element=$(e.target);
Expand Down
2 changes: 1 addition & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ en:
action_browse_collections_linktext: 'Revs collections'
tell_us_html: '%{href} what you were looking for'
tell_us_linktext: 'Tell us'
unexpected: "Oops! An unexpected error has occurred."
unexpected: "An unexpected error has occurred. If you have made changes, they might not have been saved."
500_message: "We apologize for the inconvenience. The error has been logged and we have notified system administrators. Until we fix the problem, here are some things you can do:"
actions:
delete: 'Delete'
Expand Down

0 comments on commit 43d348a

Please sign in to comment.