Autocomplete - Using Database as Source


I have been using the jQuery UI autocomplete. Currently I have all of my lookup items in an array:

var cities = ["phoenix", "los angeles", "seattle", "dallas"];

As I add more cities, I have to manually update the code and auto update my app. I want to be able to get the cities from my database and use it as a source instead of manually entering the cities in the code. Therefore, when I add a new city to my City collection, it's automatically available in the autocomplete.

This is what I have tried so far:
- Used the list service to get a list of cities from my database.
- Stored the cities in a local storage variable
- Attempted to set the local storage variable as the source using the following code:

var getCityList =;

source: getCityList,
minLength: 3,
autoFocus: true

I'm sure I'm missing a step, so any help would be greatly appreciated.

1 person has
this question