1

i have problem with using jquery-ui auto-complete for json. say, my json query return from myurl/users/listid and this is the returning data:

[{"label":"[email protected]"},{"label":"[email protected]"},{"label":"[email protected]"}]

and this is my jquery script for autocomplete.

$("#search-query").autocomplete({
    source: '/users/listid'
});

when i type something into my #search-query input box, this all three email id are shown regardless what i type. it should narrow it down to what it matches to the character i try to type. but it doesn't.

okay. this is something wierd. when i change something like following script, everything works perfect.

var data = [{"label":"[email protected]"},{"label":"[email protected]"},{"label":"[email protected]"}];

$("#search-query").autocomplete({
    source: data
});

i have totally no idea what has gone wrong. please guide me. thanks.

1 Answer 1

1

If the source is an url, autocomplete expect your own business logic in that url to filter out the options. The paramater term would be sent to the url with the input value.

Sign up to request clarification or add additional context in comments.

2 Comments

Please read jqueryui.com/autocomplete. Your should update your server side code to do the filtering.
done. i did it in my controller with parameter and the trick is at jquery parameter -> data: {term: request.term}.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.