Skip to content

Commit cfb66f5

Browse files
committed
Attempt to detect aborted requests
The error handler should not be raised if a request is aborted while another one is sent out. This attempts to detect those cases by handling the case where the error was raised and the request has a status code of 0, which should either mean we're in offline mode or the request was aborted. This closes select2#4205
1 parent fe26b08 commit cfb66f5

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/js/select2/data/ajax.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ define([
8080

8181
callback(results);
8282
}, function () {
83+
// Attempt to detect if a request was aborted
84+
// Only works if the transport exposes a status property
85+
if ($request.status && $request.status === '0') {
86+
return;
87+
}
88+
8389
self.trigger('results:message', {
8490
message: 'errorLoading'
8591
});

0 commit comments

Comments
 (0)