繁体   English   中英

Jquery UI自动完成的限制结果

[英]Limiting results of Jquery UI autocomplete

我想问一下,如何限制搜索结果。 这是一段代码,负责查询。 我只希望有五个自动完成项。

资源:

 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
         })
        );

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM