I have an autocomplete function :-
$(document).ready(function () {
$('input.autocomplete').autocomplete({
data: {
The data JSON object will be responsible for giving the associated autocomplete values, the JSON key will be the autocomplete suggestions, and the JSON value will be null.
I don't want to manually enter values inside this JSON data like:-
data:{
"Chocolate": null,
"Cake": null,
"Icecream": null,
"Pudding": null }
Instead, I want to fetch the JSON values from a text file, which will have these contents, so that I can just load the text file for this data JSON object, instead of having to manually enter it.
So, the list.txt file will have:-
"Chocolate": null,
"Cake": null,
"Icecream": null,
"Pudding": null,
"Cream:null
And I want to call this list.txt file inside JSON object data, something like:-
data: {
$.get('list.txt') }
How can I achieve this?