Ticket #6147 (closed bug: fixed)

Opened 4 years ago

Last modified 4 years ago

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:
Blocking: Blocked by:


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.element.removeClass( "ui-autocomplete-loading" );

Change History

comment:1 Changed 4 years ago by scott.gonzalez

  • Status changed from new to closed
  • Summary changed from "content is null" javascript error when source service returns empty response body to Autocomplete: Errors on empty responses
  • Resolution set to fixed
  • Milestone changed from TBD to 1.9

Fixed in  a5c1195.

comment:2 Changed 4 years ago by scott.gonzalez

  • Milestone changed from 1.9 to 1.8.6

comment:3 Changed 4 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.