From: Scott González Date: Wed, 25 Aug 2010 01:41:34 +0000 (-0400) Subject: Autocomplete: Abort existing ajax requests when running new searches. X-Git-Tag: 1.8.5~56 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=da2be6a2af88ab6e81cc64282abcc1c2703c43bb;p=jquery-ui.git Autocomplete: Abort existing ajax requests when running new searches. --- diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index 6b19c4401..e8796e41e 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -221,10 +221,14 @@ $.widget( "ui.autocomplete", { } else if ( typeof this.options.source === "string" ) { url = this.options.source; this.source = function( request, response ) { + if (self.xhr) { + self.xhr.abort(); + } self.xhr = $.getJSON( url, request, function( data, status, xhr ) { if ( xhr === self.xhr ) { - response.apply( this, arguments ); + response( data ); } + self.xhr = null; }); }; } else {