]> source.dussan.org Git - jquery-ui.git/commitdiff
Autocomplete: Handle ajax errors and timeouts. Fixes #6692 - Autocomplete: ui-autocom...
authorScott González <scott.gonzalez@gmail.com>
Wed, 1 Dec 2010 03:19:20 +0000 (22:19 -0500)
committerScott González <scott.gonzalez@gmail.com>
Wed, 1 Dec 2010 03:19:20 +0000 (22:19 -0500)
ui/jquery.ui.autocomplete.js

index 80132e2d1e70179a8b055b64a28de642a45405e5..6aefe87d6ac25978e7777e8c6ff382a42fdc0348 100644 (file)
@@ -245,11 +245,22 @@ $.widget( "ui.autocomplete", {
                                if (self.xhr) {
                                        self.xhr.abort();
                                }
-                               self.xhr = $.getJSON( url, request, function( data, status, xhr ) {
-                                       if ( xhr === self.xhr ) {
-                                               response( data );
+                               self.xhr = $.ajax({
+                                       url: url,
+                                       data: request,
+                                       dataType: "json",
+                                       success: function( data, status, xhr ) {
+                                               if ( xhr === self.xhr ) {
+                                                       response( data );
+                                               }
+                                               self.xhr = null;
+                                       },
+                                       error: function( xhr ) {
+                                               if ( xhr === self.xhr ) {
+                                                       response( [] );
+                                               }
+                                               self.xhr = null;
                                        }
-                                       self.xhr = null;
                                });
                        };
                } else {