4
I want to make suggestions dynamically with this API.
How to streamline the suggestion file by listing data from the mysql database?
Download the DEMO: https://github.com/devbridge/jQuery-Autocomplete
The archive countries.js is what contains the suggestions dictionary, but manually, I want something dynamic with the suggestions registered in the database being listed in it.
countries js.
    var countries = {
    "AD": "Andorra",
    "AE": "United Arab Emirates",
    "AF": "Afghanistan",
    "AG": "Antigua and Barbuda",
    "AI": "Anguilla",
    "AL": "Albania",
    "AM": "Armenia",
    "WK": "Wake Island",
    "WS": "Samoa",
    "YD": "People's Democratic Republic of Yemen",
    "YE": "Yemen",
    "YT": "Mayotte",
    "ZA": "South Africa",
    "ZM": "Zambia",
    "ZW": "Zimbabwe",
    "ZZ": "Unknown or Invalid Region"
}
Instructions from the API Manual
Response format The Server Response must be JSON formatted following Javascript object:
{
    // Query is not required as of version 1.2.5
    "query": "Unit",
    "suggestions": [
        { "value": "United Arab Emirates", "data": "AE" },
        { "value": "United Kingdom",       "data": "UK" },
        { "value": "United States",        "data": "US" }
    ]
}
Data can be any value or object. Data object is passed to formatResults function and onSelect callback. Alternatively, if there is no data you can only provide a string array for suggestions, such as:
{
    "query": "Unit",
    "suggestions": ["United Arab Emirates", "United Kingdom", "United States"]
}
						
Hello @vkrausser good night and thanks for your attention, could you post an example so I can understand a little better? Tks
– Rafael Assmann