From da2be6a2af88ab6e81cc64282abcc1c2703c43bb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Scott=20Gonz=C3=A1lez?= Date: Tue, 24 Aug 2010 21:41:34 -0400 Subject: [PATCH] Autocomplete: Abort existing ajax requests when running new searches. --- ui/jquery.ui.autocomplete.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 { -- 2.39.5