From 40135bb09130a56aabc0d185b62a597cb45df0dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Tue, 30 Nov 2010 22:19:20 -0500 Subject: [PATCH] Autocomplete: Handle ajax errors and timeouts. Fixes #6692 - Autocomplete: ui-autocomplete-loading class not removed when Ajax request times out. --- ui/jquery.ui.autocomplete.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index 80132e2d1..6aefe87d6 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -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 {