Browse Source

Merge pull request #5706 from wenzhixin/feature/improve-ajax

Improved the behavior of ajax abort
Dustin Utecht 4 years ago
parent
commit
db15b27a25
1 changed files with 7 additions and 0 deletions
  1. 7 0
      src/bootstrap-table.js

+ 7 - 0
src/bootstrap-table.js

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