summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2011-01-01 04:11:39 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2011-01-01 04:11:39 +0000
commit587d9d7bcff160830fe745ca43f4934b0311a65e (patch)
tree1af4f22a2687000f711c308a98a8f60dfeef45a0 /misc
parenta5325d144955bd0e28ee23cc25304a9439a07028 (diff)
downloadbrdo-587d9d7bcff160830fe745ca43f4934b0311a65e.tar.gz
brdo-587d9d7bcff160830fe745ca43f4934b0311a65e.tar.bz2
#1003828 by rfay: Fixed Drupal.ajaxError may itself throw an exception, causing silent 'AJAX Error 0' events
Diffstat (limited to 'misc')
-rw-r--r--misc/drupal.js18
1 files changed, 16 insertions, 2 deletions
diff --git a/misc/drupal.js b/misc/drupal.js
index 98b5a5418..598cec32d 100644
--- a/misc/drupal.js
+++ b/misc/drupal.js
@@ -314,8 +314,22 @@ Drupal.ajaxError = function (xmlhttp, uri) {
}
statusCode += "\n" + Drupal.t("Debugging information follows.");
pathText = "\n" + Drupal.t("Path: !uri", {'!uri': uri} );
- statusText = xmlhttp.statusText ? ("\n" + Drupal.t("StatusText: !statusText", {'!statusText': $.trim(xmlhttp.statusText)})) : "";
- responseText = xmlhttp.responseText ? ("\n" + Drupal.t("ResponseText: !responseText", {'!responseText': $.trim(xmlhttp.responseText)})) : "";
+ statusText = '';
+ // 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.
responseText = responseText.replace(/<("[^"]*"|'[^']*'|[^'">])*>/gi,"");
responseText = responseText.replace(/[\n]+\s+/g,"\n");