Skip to content

Commit 40135bb

Browse files
committed
Autocomplete: Handle ajax errors and timeouts. Fixes #6692 - Autocomplete: ui-autocomplete-loading class not removed when Ajax request times out.
1 parent ddb4694 commit 40135bb

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

ui/jquery.ui.autocomplete.js

+15-4
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,22 @@ $.widget( "ui.autocomplete", {
245245
if (self.xhr) {
246246
self.xhr.abort();
247247
}
248-
self.xhr = $.getJSON( url, request, function( data, status, xhr ) {
249-
if ( xhr === self.xhr ) {
250-
response( data );
248+
self.xhr = $.ajax({
249+
url: url,
250+
data: request,
251+
dataType: "json",
252+
success: function( data, status, xhr ) {
253+
if ( xhr === self.xhr ) {
254+
response( data );
255+
}
256+
self.xhr = null;
257+
},
258+
error: function( xhr ) {
259+
if ( xhr === self.xhr ) {
260+
response( [] );
261+
}
262+
self.xhr = null;
251263
}
252-
self.xhr = null;
253264
});
254265
};
255266
} else {

0 commit comments

Comments
 (0)