0

I have put an exposed filter on my page, which is an auto-submit textbox without any submit button. When I put the focus on this textbox and refresh the page with no value inside the textbox, the page gives me an error which is caused by emptiness of the textbox.

**Error:**
An AJAX HTTP request terminated abnormally.
Debugging information follows.
Path: /************/views/ajax
StatusText: 
ResponseText: 
ReadyState: 4

What is your solution for it?

1 Answer 1

2

When you give the focus to your field, it triggers an ajax call to the server. If you reload the page right away, it breaks the ajax call and throw this error in an alert.

This only happens as you reload the page during an ajax call. As far as i know you can't do anything about it, unless you modify the core I guess - which is "unclean".

You could use the classes added in css to display a loader while there is an ajax call to the server, and let the user know the page is working on something.

EDIT:

Thanks to clive's comment I actually got rid of this alert by overriding Drupal's Drupal.ajax.prototype.error function.

In a js file, you can add :

Drupal.ajax.prototype.error = function (response, uri) {
  // Remove the progress element.
  if (this.progress.element) {
    $(this.progress.element).remove();
  }
  if (this.progress.object) {
    this.progress.object.stopMonitoring();
  }
  // Undo hide.
  $(this.wrapper).show();
  // Re-enable the element.
  $(this.element).removeClass('progress-disabled').removeAttr('disabled');
  // Reattach behaviors, if they were detached in beforeSerialize().
  if (this.form) {
    var settings = response.settings || this.settings || Drupal.settings;
    Drupal.attachBehaviors(this.form, settings);
  }
};

This is a copy of the original error handler callback without the alert() function. This will remove your message, but will also hide any error message returned by Drupal's Ajax.

2
  • 1
    The message comes from Drupal.ajax.prototype.error, but it's invoked from Drupal.ajax itself. The latter would need to be monkey patched to change that behaviour, no need to edit anything in core as such
    – Clive
    Commented Jan 21, 2015 at 14:04
  • 1
    Thanks for your wise comment! I just tested, and your right, no need to modify the code. I updated my answer. Commented Jan 21, 2015 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.