Skip to content

Instantly share code, notes, and snippets.

@rgkimball
Created April 13, 2015 15:14
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 rgkimball/cc92980dad3af6e4f844 to your computer and use it in GitHub Desktop.
Save rgkimball/cc92980dad3af6e4f844 to your computer and use it in GitHub Desktop.
Prevents Drupal from throwing alert()s when AJAX is interrupted.
preventAlerts: function () {
//Copy drupal's original error function for later use if you want
Drupal.ajax.prototype.original_error = Drupal.ajax.prototype.error;
Drupal.ajax.prototype.error = function (response, uri) {
// This should catch the "terminated abnormally" error
if (response.readyState == 0 || response.readyState == 4) {
console.log(response);
}
else {
this.original_error(response, uri);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment