I have the following json hard code,
var dataLocality = [
{ "label": "Arwen" },
{ "label": "Bilbo Baggins" },
{ "label": "Boromir" },
{ "label": "Frodo Baggins" },
{ "label": "Peregrin Pippin Took" },
{ "label": "Samwise Gamgee" }
];
What I use to fill in an autocomplete text box with the following script,
$(function () {
$("#locality").autocomplete(
{
source: dataLocality
})
});
Now I have a text file that is dynamically updated through my application called dataLocality.text, which I can download and view in a warning window with this code,
function codeAddress() {
jQuery.get('http://localhost/project/jSonDocs/dataWhat.txt', function (data) {
var dataLocality = data;
alert(dataLocality);
});
}
window.onload = codeAddress;
But I canβt figure out how to get data from var dataLocalitytosource: dataLocality
The data in my text document is as follows:
[
{ "label": "Arwen" },
{ "label": "Bilbo Baggins" },
{ "label": "Boromir" },
{ "label": "Frodo Baggins" },
{ "label": "Peregrin Pippin Took" },
{ "label": "Samwise Gamgee" }
];
source
share