Index: misc/ahah.js
===================================================================
RCS file: /cvs/drupal/drupal/misc/ahah.js,v
retrieving revision 1.6
diff -u -r1.6 ahah.js
--- misc/ahah.js	19 Nov 2007 10:05:48 -0000	1.6
+++ misc/ahah.js	31 Dec 2007 18:30:08 -0000
@@ -85,8 +85,8 @@
       return ahah.success(response, status);
     },
     complete: function(response, status) {
-      if (status == 'error') {
-        return ahah.error(response.responseText);
+      if (status == 'error' || status == 'parsererror') {
+        return ahah.error(response, ahah.url);
       }
     },
     dataType: 'json',
@@ -194,10 +194,10 @@
 /**
  * Handler for the form redirection error.
  */
-Drupal.ahah.prototype.error = function (error) {
-  alert(Drupal.t('An error occurred:\n\n@error', { '@error': error }));
+Drupal.ahah.prototype.error = function (response, uri) {
+  alert(Drupal.ahahError(response, uri));
   // Resore the previous action and target to the form.
-  element.parent('form').attr( { action: this.form_action, target: this.form_target} );
+  $(this.element).parent('form').attr( { action: this.form_action, target: this.form_target} );
   // Remove the progress element.
   if (this.progress.element) {
     $(this.progress.element).remove();

Index: misc/autocomplete.js
===================================================================
RCS file: /cvs/drupal/drupal/misc/autocomplete.js,v
retrieving revision 1.22
diff -u -r1.22 autocomplete.js
--- misc/autocomplete.js	21 Oct 2007 18:59:01 -0000	1.22
+++ misc/autocomplete.js	31 Dec 2007 18:28:50 -0000
@@ -282,7 +282,7 @@
         }
       },
       error: function (xmlhttp) {
-        alert(Drupal.t("An HTTP error @status occurred. \n@uri", { '@status': xmlhttp.status, '@uri': db.uri }));
+        alert(Drupal.ahahError(xmlhttp, db.uri));
       }
     });
   }, this.delay);
Index: misc/progress.js
===================================================================
RCS file: /cvs/drupal/drupal/misc/progress.js,v
retrieving revision 1.19
diff -u -r1.19 progress.js
--- misc/progress.js	21 Oct 2007 18:59:01 -0000	1.19
+++ misc/progress.js	31 Dec 2007 18:28:51 -0000
@@ -85,7 +85,7 @@
         pb.timer = setTimeout(function() { pb.sendPing(); }, pb.delay);
       },
       error: function (xmlhttp) {
-        pb.displayError(Drupal.t("An HTTP error @status occurred. \n@uri", { '@status': xmlhttp.status, '@uri': pb.uri }));
+        pb.displayError(Drupal.ahahError(xmlhttp, pb.uri));
       }
     });
   }
Index: misc/drupal.js
===================================================================
RCS file: /cvs/drupal/drupal/misc/drupal.js,v
retrieving revision 1.40
diff -u -r1.40 drupal.js
--- misc/drupal.js	5 Oct 2007 09:35:08 -0000	1.40
+++ misc/drupal.js	31 Dec 2007 18:28:50 -0000
@@ -246,6 +246,24 @@
   return { 'start': element.selectionStart, 'end': element.selectionEnd };
 };
 
+/**
+ * Build an error message from ahah response.
+ */
+Drupal.ahahError = function(xmlhttp, uri) {
+  if (xmlhttp.status == 200) {
+    if (jQuery.trim($(xmlhttp.responseText).text())) {
+      var message = Drupal.t("An error occurred. \n@uri\n@text", {'@uri': uri, '@text': xmlhttp.responseText });
+    }
+    else {
+      var message = Drupal.t("An error occurred. \n@uri\n(no information available).", {'@uri': uri, '@text': xmlhttp.responseText });
+    }
+  }
+  else {
+    var message = Drupal.t("An HTTP error @status occurred. \n@uri", {'@uri': uri, '@status': xmlhttp.status });
+  }
+  return message;
+}
+
 // Global Killswitch on the <html> element
 if (Drupal.jsEnabled) {
   // Global Killswitch on the <html> element
