Skip to content
Snippets Groups Projects
Commit 587d9d7b authored by Angie Byron's avatar Angie Byron
Browse files

#1003828 by rfay: Fixed Drupal.ajaxError may itself throw an exception,...

#1003828 by rfay: Fixed Drupal.ajaxError may itself throw an exception, causing silent 'AJAX Error 0' events
parent a5325d14
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -314,8 +314,22 @@ Drupal.ajaxError = function (xmlhttp, uri) { ...@@ -314,8 +314,22 @@ Drupal.ajaxError = function (xmlhttp, uri) {
} }
statusCode += "\n" + Drupal.t("Debugging information follows."); statusCode += "\n" + Drupal.t("Debugging information follows.");
pathText = "\n" + Drupal.t("Path: !uri", {'!uri': uri} ); pathText = "\n" + Drupal.t("Path: !uri", {'!uri': uri} );
statusText = xmlhttp.statusText ? ("\n" + Drupal.t("StatusText: !statusText", {'!statusText': $.trim(xmlhttp.statusText)})) : ""; statusText = '';
responseText = xmlhttp.responseText ? ("\n" + Drupal.t("ResponseText: !responseText", {'!responseText': $.trim(xmlhttp.responseText)})) : ""; // In some cases, when statusCode == 0, xmlhttp.statusText may not be defined.
// Unfortunately, testing for it with typeof, etc, doesn't seem to catch that
// and the test causes an exception. So we need to catch the exception here.
try {
statusText = "\n" + Drupal.t("StatusText: !statusText", {'!statusText': $.trim(xmlhttp.statusText)});
}
catch (e) {}
responseText = '';
// Again, we don't have a way to know for sure whether accessing
// xmlhttp.responseText is going to throw an exception. So we'll catch it.
try {
responseText = "\n" + Drupal.t("ResponseText: !responseText", {'!responseText': $.trim(xmlhttp.responseText) } );
} catch (e) {}
// Make the responseText more readable by stripping HTML tags and newlines. // Make the responseText more readable by stripping HTML tags and newlines.
responseText = responseText.replace(/<("[^"]*"|'[^']*'|[^'">])*>/gi,""); responseText = responseText.replace(/<("[^"]*"|'[^']*'|[^'">])*>/gi,"");
responseText = responseText.replace(/[\n]+\s+/g,"\n"); responseText = responseText.replace(/[\n]+\s+/g,"\n");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment