Permalink
Browse files

Autocomplete: Handle ajax errors and timeouts. Fixes #6692 - Autocomp…

…lete: ui-autocomplete-loading class not removed when Ajax request times out.
  • Loading branch information...
1 parent ddb4694 commit 40135bb09130a56aabc0d185b62a597cb45df0dc @scottgonzalez scottgonzalez committed Dec 1, 2010
Showing with 15 additions and 4 deletions.
  1. +15 −4 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 {

0 comments on commit 40135bb

Please sign in to comment.