2013-06-03 84 views
1

异常警报在我的Drupal鉴于我激活了阿贾克斯,在我的前端一切正常,但是当用户做出一个Ajax请求,然后他切换到其他页面(之前,他得到了来自阿贾克斯的响应请求)我看到此警报一个AJAX HTTP请求终止在Drupal

An AJAX HTTP request terminated abnormally. 
Debugging information follows. 
Path: /en/views/ajax 
StatusText: 
ResponseText: 
ReadyState: 4 
+2

这是因为ajax请求没有完成,并且用户请求了新的页面! –

回答

1

发生此错误是因为它是在Drupal中处理AJAX错误的标准方法。如果您提交表单,而AJAX请求正在处理,您将收到错误。

这个错误实际上是Drupal和Drupal的预期目的是通过Drupal.ajax.prototype.error = function (response, uri)结合Drupal.ajaxError = function (xmlhttp, uri)在Drupal 7的misc/drupal.js文件中引发此错误。

请注意,这是比问题更多的UX问题。

上有用于固定它的Drupal 8

为Drupal 7关于Drupal alerts "An AJAX HTTP request terminated abnormally" during normal site operation, confusing site visitors/editors Drupal站点悬而未决的问题,你可以尝试应用以下核心补丁:D7-fix_autocomplete_terminated_error-1232416-179-do-not-test.patch出外:

--- a/misc/ajax.js 
+++ b/misc/ajax.js 
@@ -448,7 +448,10 @@ Drupal.ajax.prototype.getEffect = function (response) { 
    * Handler for the form redirection error. 
    */ 
Drupal.ajax.prototype.error = function (response, uri) { 
- alert(Drupal.ajaxError(response, uri)); 
+ // Fix for autocomplete terminated error. 
+ if (response.status != 0) { 
+ alert(Drupal.ajaxError(response, uri)); 
+ } 
    // Remove the progress element. 
    if (this.progress.element) { 
    $(this.progress.element).remove(); 
diff --git a/misc/autocomplete.js b/misc/autocomplete.js 
index 8f7ac60..980c1ca 100644 
--- a/misc/autocomplete.js 
+++ b/misc/autocomplete.js 
@@ -306,7 +306,10 @@ Drupal.ACDB.prototype.search = function (searchString) { 
     } 
     }, 
     error: function (xmlhttp) { 
-  alert(Drupal.ajaxError(xmlhttp, db.uri)); 
+  // Fix for autocomplete terminated error. 
+  if (xmlhttp.status != 0) { 
+   alert(Drupal.ajaxError(xmlhttp, db.uri)); 
+  } 
     } 
    }); 
    }, this.delay); 
0

这里的一个简单的方法来解决这个问题:

$(document).ajaxError(function() { 
 
     donotshowajayerror; // prevent ajax errors alerts 
 
});

写一些破碎的代码,所以它会停止在该行执行javascript。