Skip to content

Instantly share code, notes, and snippets.

@DivineDominion
Last active December 15, 2015 13:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DivineDominion/5269849 to your computer and use it in GitHub Desktop.
Save DivineDominion/5269849 to your computer and use it in GitHub Desktop.

Where, instead of my inefficient approach, I execute XHR JavaScript responses. Behaves just like JangoSteve said it should for 400 or 424 HTTP response status codes.

Binds the event on $(document) so that dynamically created forms will be affected, too.

$(document).ready(function() {
$(document).on('ajax:error', 'form[data-remote="true"]', function(evt, xhr, status) {
eval(xhr.responseText);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment