0 votes
553 views
in Drupal by (26.0k points)
edited
Fixing "AJAX request not completed correctly" error in Drupal

1 Answer

0 votes
by (26.0k points)
 
Best answer

Drupal 7 has a wonderful AJAX Framework. But the developers made that all errors in its work (and they can happen out of the blue) are thrown out on the user in the form of a javascript alert window. In English, this message looks like this: An AJAX HTTP request terminated abnormally. Debugging information follows. Path: / system / ajax StatusText: ResponseText: ReadyState: 4

This error often appears when the ajax request is still ongoing (the server is doing some long work), the progress indicator is spinning, and the user clicked on the link on the page to leave it. I adhere to the internal belief that displaying messages to the user using alerts is bad manners. They are ugly, they look different in different browsers and operating systems and they scare the user. In general, one negative.

That is why we will output all alerts to the browser console (if any). To do this, add the following line to any javascript file (for example, in our drupal theme or in our own module):

window.alert = function(arg) {
  if (window.console && console.log) {
    console.log(arg);
  }
};

This is how we override the javascript alert function and tell it that instead of creating a window with a button, we need to write everything to the console.

Alternatively you can use https://www.drupal.org/project/ajax_error_behavior module. 

...