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 https://github.com/select2/select2/issues/4205
This commit is contained in:
parent
fe26b083eb
commit
cfb66f5e4f
6
src/js/select2/data/ajax.js
vendored
6
src/js/select2/data/ajax.js
vendored
@ -80,6 +80,12 @@ define([
|
|||||||
|
|
||||||
callback(results);
|
callback(results);
|
||||||
}, function () {
|
}, function () {
|
||||||
|
// Attempt to detect if a request was aborted
|
||||||
|
// Only works if the transport exposes a status property
|
||||||
|
if ($request.status && $request.status === '0') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
self.trigger('results:message', {
|
self.trigger('results:message', {
|
||||||
message: 'errorLoading'
|
message: 'errorLoading'
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user