Skip to main content

Search and Top Navigation

#6147 closed bug (fixed)

Opened October 05, 2010 02:54PM UTC

Closed October 05, 2010 03:10PM UTC

Last modified November 19, 2010 06:26PM UTC

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" );
};
Attachments (0)
Change History (3)

Changed October 05, 2010 03:10PM UTC by scottgonzalez comment:1

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.

Changed October 25, 2010 06:55PM UTC by scottgonzalez comment:2

milestone: 1.91.8.6

Changed November 19, 2010 06:26PM UTC by Scott González comment:3

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

Changeset: a5c119558b0b40633269c7565339e5b20754c3d8