致力于搜索框的预输入功能,我正在js文件中手动定义术语。取而代之的是,我需要通过url在外部解析 data:[] 的json响应。我该如何做到这一点。
jQuery.typeahead({
input: '.js-typeahead-search_v1',
order: "desc",
source: {
data: [
"Andorra", "Angola", "Antigua and Barbuda",
"Uzbekistan", "Vanuatu", "Venezuela", "Vietnam", "Yemen", "Zambia", "Zimbabwe"
]
},
callback: {
onInit: function (node) {
console.log('Typeahead Initiated on ' + node.selector);
}
}
});