I often have incorrect results from the ajax search in the backend with select2, because several requests are sent when typing and the wrong one responds last. Especially with several 10'000 posts that have to be searched. A strategy is needed that no longer waits for the results of previously sent requests before sending new. A strategy like the following could be useful.
var $ajaxReq = 'ToCancelPrevReq';
$ajaxReq = jQuery.ajax({
beforeSend: function() {
if($ajaxReq != 'ToCancelPrevReq' && $ajaxReq.readyState < 4)
{
$ajaxReq.abort();
}
}
})