Then I have a list of provinces that recovery from db and turn into json. All'autocomplete I serve this file province.php that return a list of all the provinces. The file does is show all the provinces with the simple query SELECT * FROM provinces.
I was forced to choose this path so as to put this cached result and avoid No database queries only to the choice of the province.
The real problem is what?
That autocomplete works in his own way or does see the list of all the provinces province.php extracted from the file, but it is not able to filter the results.
So if I write MILA ... should show only the provinces that boarders with MILA .. because instead always gives me the entire list?
<script>
$(function() {
$( "#province" ).autocomplete({
source: 'province.php'
});
});
</script>
The file province.php returns something like this:
{"0":{"id":"1","label":"Milano","value":"Milano"},"1":{"id":"2","label":"Cagliari","value":"Cagliari"},"2":{"id":"3","label":"Messina","value":"Messina"},"5":{"id":"4","label":"Roma","value":"Roma"},"6":{"id":"5","label":"Venezia","value":"Venezia"}}
As if I do this instead works:
<script>
$(function() {
var province = [
{ label: "milano", value: "milano", id: 1 },
{ label: "Cagliari", value: "Cagliari", id: 2 },
{ label: "Messina", value: "Messina", id: 3 },
{ label: "Roma", value: "Roma", id: 4 },
{ label: "Catania", value: "Catania", id: 5 },
{ label: "Venezia", value: "Venezia", id: 6 }
];
$( "#tags" ).autocomplete({
source: province
});
});
</script>
why?