gpt4 book ai didi

php - Typeahead.js 出现问题

转载 作者:行者123 更新时间:2023-11-30 01:11:48 26 4
gpt4 key购买 nike

我一直在尝试在我的项目中使用 typeahead.js。我需要来自 mysql 数据库的数据。但没有任何建议。我几乎已经尝试了一切。这是我的代码:

HTML 文件:

    <html lang="en">
<head>
<meta charset="utf-8" />
<title>jQuery UI Autocomplete - Default functionality</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script src="js/typeahead.js"></script>
</head>
<body>

<div class="ui-widget">
<label for="tags">Companies: </label>
<input id="tags"/>
</div>

<script>
$('#tags').typeahead({
name: 'tags',
prefetch: 'file.json'
});
</script>
</body>
</html>

文件.json

    [ 
{
"value": "Maini Optics",
"tokens": ["Maini","Optics"]
},
{
"value": "Prakash Eyewear",
"tokens": ["Prakash","Eyewear"]
},
{
"value": "Eternity Lifestyles",
"tokens": ["Eternity","Lifestyles"]
},
{
"value": "Aeurole Inspecs",
"tokens": ["Aeurole","Inspecs"]
},
{
"value": "Dynamic Eyewear",
"tokens": ["Dynamic","Eyewear"]
},
{
"value": "abc",
"tokens": ["abc"]
},
{
"value": "Test",
"tokens": ["Test"]
}
]

请帮忙...

最佳答案

您必须提供姓名

{ 
"value": "Maini Optics",
"name": "Maini Optics",
"tokens": ["Maini","Optics"]
}

关于php - Typeahead.js 出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19404366/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com