Autocomplete: Handle ajax errors and timeouts. Fixes #6692 - Autocomplete: ui-autocomplete-loading class not removed when Ajax request times out.

This commit is contained in:
Scott González 2010-11-30 22:19:20 -05:00
parent ddb4694cc1
commit 40135bb091

View 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 {