From: Scott González Date: Wed, 1 Dec 2010 03:19:20 +0000 (-0500) Subject: Autocomplete: Handle ajax errors and timeouts. Fixes #6692 - Autocomplete: ui-autocom... X-Git-Tag: 1.8.7~11 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=40135bb09130a56aabc0d185b62a597cb45df0dc;p=jquery-ui.git Autocomplete: Handle ajax errors and timeouts. Fixes #6692 - Autocomplete: ui-autocomplete-loading class not removed when Ajax request times out. --- 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 {