I created an autocomplete function, when I console.log it displays me all my files that is in remote JSON file, but When I try to display it when I start Type on input it doesn't show nothing, no errors but it doesn't work at all. Also I want to make this multi select autocomplete. But right now I want it only display suggestions when I start type on input.
$(function () {
$("#city").autocomplete({
source: function (request, response) {
$.ajax({
url: $('#city').attr('data-source'),
success: function (data) {
for (var i = 0; i < data.length; i++) {
data[i].loc_name
}
}
})
}
})
})
JSON
[{"population":1729119,"token":"167|7|179|1296|55544|0","loc_name":"Warszawa"},{"population":758463,"token":"167|6|135|976|7644|0","loc_name":"Krak\u00f3w"},{"population":718960,"token":"167|5|113|789|58247|25218","loc_name":"\u0141\u00f3d\u017a Teofil\u00f3w"},{"population":718960,"token":"167|5|113|789|58247|25340","loc_name":"\u0141\u00f3d\u017a G\u00f3rna"},{"population":718960,"token":"167|5|113|789|58247|25282","loc_name":"\u0141\u00f3d\u017a \u0141askowice"}]