使用自动完成功能和自定义结果。当我将鼠标悬停在结果上时,我 出现以下错误:
未捕获的TypeError:无法读取未定义的属性“值”
结果按预期返回,但是当我们将鼠标悬停在 结果
json数据:
[{"id":"23","fname":"Joe","state":"1"},
{"id":"24","fname":"Test","state":"1"}]
自动完成通话:
$( ".headsearch" ).autocomplete({
source: function( request, response ) {
$.ajax({
url: "<?php echo base_url();?>search",
type: 'post',
dataType: 'JSON',
data: {
search: request.term
},
success: function( data ) {
// console.log(data);
response( data );
}
});
},
minLength : 2,
}).data( "ui-autocomplete" )._renderItem = function( ul, item ) {
return $( "<li>" )
.data( "ui-autocomplete-item", item )
.append( "<a>" + item.id + "|" + item.fname + "|" + item.state + "</a>" )
.appendTo( ul );
};