首页 > 解决方案 > 处理 Typeahead 和外部 JSON 输入不起作用

问题描述

处理搜索框的预输入功能,我在 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);
        }
    }
});

标签: javascriptjqueryajax

解决方案


推荐阅读