Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#6147 closed bug (fixed)

Autocomplete: Errors on empty responses

Reported by: clewis Owned by:
Priority: major Milestone: 1.8.6
Component: ui.autocomplete Version: 1.8.5
Keywords: Cc:
Blocked by: Blocking:

Description

PROBLEM: When the source is a service and it returns an empty response body, a javascript error occurs. Some service languages, such as .net, will return an empty body when the request is terminated mid stream, such as pressing enter in the text box too fast before the suggestions are displayed.

CAUSE: The response handler does not check to see if the content parameter is null before attempting to check its length.

WORKAROUND: override the response handler in the following manner to mitigate the issue:

$.ui.autocomplete.prototype._response = function( content ) {
	if ( content && content.length ) {
		content = this._normalize( content );
		this._suggest( content );
		this._trigger( "open" );
	} else {
		this.close();
	}
	this.element.removeClass( "ui-autocomplete-loading" );
};

Change History (3)

comment:1 Changed 12 years ago by Scott González

Milestone: TBD1.9
Resolution: fixed
Status: newclosed
Summary: "content is null" javascript error when source service returns empty response bodyAutocomplete: Errors on empty responses

Fixed in a5c1195.

comment:2 Changed 12 years ago by Scott González

Milestone: 1.91.8.6

comment:3 Changed 12 years ago by Scott González

Autocomplete: Make sure we have a response before trying to check the length. Fixes #6147 - Autocomplete: Errors on empty responses.

Changeset: a5c119558b0b40633269c7565339e5b20754c3d8

Note: See TracTickets for help on using tickets.