我正在尝试使用 jQuery UI Autocomplete 插件创建类似于 Google 的站点搜索。问题是我的网站搜索字符串“[object Object]”而不是我单击的值。每个选择都返回:“您对“[object Object]”的搜索未匹配任何产品。”
<script>
$(function () {
var availableTags = [
"SEO",
"Responsive Web Design",
"Google Local",
"Twitter",
"Social Media",
"Web Design",
"What is Google Authorship",
"NFL",
"Contact Advanced IFX",
"Search Engine Optimization",
"Kevin Sullivan",
"Fantasy Football RB Rankings 2013",
"Fantasy Football",
"How to Buy Twitter Followers",
"Advanced IFX",
"Social Media Marketing",
"Advanced Marketing Trends",
"NFL Schedule 2013-2014 Season",
"Fantasy Football Breakdown",
];
$(".search_box").autocomplete({
source: availableTags,
select: function (event, ui) {
var searchTerm = ui.item;
$('.search_box').val(searchTerm);
$('form.search').submit();
}
});
});