]> source.dussan.org Git - jquery-ui.git/commitdiff
Autocomplete: Abort existing ajax requests when running new searches.
authorScott González <scott.gonzalez@gmail.com>
Wed, 25 Aug 2010 01:41:34 +0000 (21:41 -0400)
committerScott González <scott.gonzalez@gmail.com>
Wed, 25 Aug 2010 01:41:34 +0000 (21:41 -0400)
ui/jquery.ui.autocomplete.js

index 6b19c440163d238a5af04677861b66d2d8111cfe..e8796e41e693c3eef3faaf0f594ee920be5482d5 100644 (file)
@@ -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 {