我的代码很少,但是没有用,我无法理解为什么。 如果有人告诉我我哪里错了,请,
var data = {
"sugestii":[{
"nume":"Hunedoara (tot judeţul)",
"id":"123220",
"tip":2
},{
"nume":"Hunedoara (din judeţul Hunedoara)",
"id":"126958",
"tip":1
},{
"nume":"Hunia (din judeţul Dolj)",
"id":"101566",
"tip":1
},{
"nume":"Hunedoara Timisana (din judeţul Arad)",
"id":"14257",
"tip":1
}]
}
// setup autocomplete function pulling from data [] array
$('#autocomplete').autocomplete({
lookup: data,
onSelect: function (suggestion) {
var thehtml = '<strong>data Name:</strong> ' + suggestion.nume + ' <br> <strong>Symbol:</strong> ' + suggestion.id;
$('#outputcontent').html(thehtml);
}
});
答案 0 :(得分:0)
相信在自动完成中没有选项作为查找,尝试用source替换查找。阅读http://api.jqueryui.com/autocomplete/
答案 1 :(得分:0)
你可以像这样使用自动完成的成功方法,希望能帮助你...
success: function (data) {
response($.map(data, function (item) {
return {
label: item.name,
value: item.id
};
}));
}