开发者

jQuery autocomplete only displays results sometimes?

I have an autocomplete on a textbox, but it only works some of the time and I can't figure out why. The method I tell it to call returns a Json object that is a list of peoples names that it retrieves from active directory. For some reason the autocomplete won't display them after the user types in three or more characters, even if the search returns a list of names.

The code in the view is like this:

<i开发者_运维技巧nput type="text" id="nominee_name" />
    <script type="text/javascript" language="javascript">
    $(function () {
        $('#nominee_name').autocomplete({
            source: function (request, response) {
                $.ajax({
                    url: "/cap/findnames", type: "POST", dataType: "json",
                    data: { searchText: request.term, maxResults: 10 },
                    success: function (data) {
                        response($.map(data, function (item) {
                            return { label: item.FullName, value: item.FullName, id: item.FullName }
                        }))
                    }
                })
            }
        });
    });
    </script>

So for example, typing "Da" will display a bunch of Dave's in the autocomplete box, but typing "Dave" will display nothing. Any ideas?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜