我想问一下,如何限制搜索结果。这是一段代码,负责查询。我只希望有五个自动完成项。
资源:
function( request, response ) {
$.ajax({
type : 'post',
dataType: "json",
data: {
'person':request
},
url: 'PersonWatch/all',
success: function(data) {
response( $.map( data, function(item, i) {
return item.person
}));
}
});
}
尝试
response($.map(data, function(item, i) {
return i < 5 ? item.person : null
})
);
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句