Skip to content
This repository has been archived by the owner on Mar 16, 2018. It is now read-only.

Term filtering bug #4

Closed
AlexandraK opened this issue Jan 10, 2011 · 1 comment
Closed

Term filtering bug #4

AlexandraK opened this issue Jan 10, 2011 · 1 comment

Comments

@AlexandraK
Copy link

Hi

I wrote a detailed explanation about this here:
http://stackoverflow.com/questions/4643469/jquery-autocomplete-plugin

basically if you type 1 character, or a string of random characters you'll get a list of all terms.
Any solution for this? :(

@agarzola
Copy link
Owner

Hello, Alexandra!

I answered your question on SO, but will repeat it here for the sake of other people who may encounter the same issue and come here before SO.

In the case of using a url for the data, the script sends the request as whatever you set in the specified url, and adds q=[current input value] at the end. In the case of initial load when you type in “a”, this is sent to your backend script: localhost/boo/?get_suggestions=1&q=a. Thus, autocompelte.js expects this initial query to produce only items that match the query. After that initial request, the script will take on the filtering subsets internally, to decrease server load. This explains why “ac” returns only items that match your criteria. This is the autocomplete script doing its job of filtering what the server gave it.

If I’m interpreting your backend code correctly, it makes no use whatsoever of the q parameter being sent in the request, so your code is returning every possible term. Autocomplete presumes this is the result of a proper search and shows you all of it, waiting for more characters to be typed in for it to filter the list further.

The point being that you need to make your backend script filter the list of terms to whatever matches the q parameter before returning it to the autocomplete script.

Let me know if I can be of further assistance!

This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants