浏览代码

Improved the behavior of ajax abort

zhixin 4 年之前
父节点
当前提交
d009522902
共有 1 个文件被更改,包括 7 次插入0 次删除
  1. 7 0
      src/bootstrap-table.js

+ 7 - 0
src/bootstrap-table.js

@@ -1951,6 +1951,12 @@ class BootstrapTable {
         }
       },
       error: jqXHR => {
+        // abort ajax by multiple request
+        if (jqXHR && jqXHR.status === 0 && this._xhrAbort) {
+          this._xhrAbort = false
+          return
+        }
+
         let data = []
 
         if (this.options.sidePagination === 'server') {
@@ -1968,6 +1974,7 @@ class BootstrapTable {
       Utils.calculateObjectValue(this, this.options.ajax, [request], null)
     } else {
       if (this._xhr && this._xhr.readyState !== 4) {
+        this._xhrAbort = true
         this._xhr.abort()
       }
       this._xhr = $.ajax(request)