From 40a19ae8fd0f6fb1f46d3c21d11447e741ceca31 Mon Sep 17 00:00:00 2001 From: morning-star <26325820+Sight-wcg@users.noreply.github.com> Date: Fri, 28 Mar 2025 17:18:42 +0800 Subject: [PATCH] =?UTF-8?q?fix(table):=20=E4=BF=AE=E5=A4=8D=E7=AB=9E?= =?UTF-8?q?=E6=80=81=E9=97=AE=E9=A2=98=20(#2584)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/table.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/modules/table.js b/src/modules/table.js index f36ee000..99256373 100644 --- a/src/modules/table.js +++ b/src/modules/table.js @@ -1195,7 +1195,12 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ that.loading(true); - $.ajax({ + // 4:代表响应已完成 + if (that._xhr && that._xhr.readyState !== 4) { + that._xhrAbort = true; + that._xhr.abort(); + } + that._xhr = $.ajax({ type: options.method || 'get', url: options.url, contentType: options.contentType, @@ -1236,6 +1241,10 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ done(res, opts.type); }, error: function(e, msg){ + if (e && e.status === 0 && that._xhrAbort){ + that._xhrAbort = false; + return; + } that.errorView('请求异常,错误提示:'+ msg); typeof options.error === 'function' && options.error(e, msg); }