abort ajax search to avoid wrong search results in select2

Support General abort ajax search to avoid wrong search results in select2

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #46989
    Berg InformatikBerg Informatik
    Participant

    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();
    		}
    	}
    })
    #46998
    PeterPeter
    Moderator

    Hello Berg,

    This is an interesting idea when you have a large amount of data with many posts. I will forward this topic to the development team to research and implement a feature for this case.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.