Jquery Typeahead 不从 JSON 返回数据

问题描述 投票:0回答:0

我正在做一个项目,当输入一些数据时需要提前输入文本框,并且数据将使用查询字符串从网络服务中获取。

我只想显示姓名、州代码、邮政编码和邮政编码类型,目前无法正常工作。

这是我用示例 JSON 字符串编写的代码

<script>
$.typeahead({
    input: '.js-typeahead-city',
    order: "desc",
    source: {
        data: [
                {
                    "Value":"Boston, KY 40107 - Standard",
                    "Name":"Boston",
                    "Type":"Prefered",
                    "ZipCode":"40107",
                    "ZipCodeType":"Standard",
                    "StateCode":"KY",
                    "StateName":"Kentucky",
                    "StateFIPS":"21",
                    "CountryCode":"US",
                    "ContryName":null,
                    "Latitude":37.753515,
                    "Longitude":-85.637791,
                    "Country":"Nelson"
                    "ContryFIPS":"21179"
                    "TimeZone":"Eastern",
                    "GMT":-5,
                    "AreaCode":"502"
                },
                {
                    "Value":"Boston, MA 02111 - Standard",
                    "Name":"Boston",
                    "Type":"Prefered",
                    "ZipCode":"02111",
                    "ZipCodeType":"Standard",
                    "StateCode":"MA",
                    "StateName":"Massachusetts",
                    "StateFIPS":"25",
                    "CountryCode":"US",
                    "ContryName":null,
                    "Latitude":42.351267,
                    "Longitude":-71.064699,
                    "Country":"Suffolk"
                    "ContryFIPS":"25025"
                    "TimeZone":"Eastern",
                    "GMT":-5,
                    "AreaCode":"617"
                },
            ]
    },
    callback: {
        onInit: function (node) {
            console.log('Typeahead Initiated on ' + node.selector);
        }
    }
});        
</script>
jquery typeahead.js
© www.soinside.com 2019 - 2024. All rights reserved.