I've got a problem with my autocomplete script... If I use my json file all my data are displayed but autocomplete doesn't work.. In contrast, if I use the table NPA, it works...
Someone can help me about this problem ? Thanks !
My autocomplete.php
var NPA = 'npa.json';
var NPA2 = [{"value": "1700","label": "NewYork City"},{"value": "1701","label": "Chicago"}];
$('#tags').autocomplete({
source: NPA2,
minLength: 1
});
My npa.json :
[{"value": "1700","label": "NewYork City"},{"value": "1701","label": "Chicago"}]
Your content of NPA
should be the string of npa.json
. And not the content of this file.
Yo should load the content of the json file :
var NPA = 'npa.json';
$.getJSON(NPA, function(data) {
$('#tags').autocomplete({
source: data,
minLength: 1
});
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.