Jquery Autocomplete not showing results [closed]

2019-07-08 21:05发布

I have the following code:

var acOptions = {
             source:function (request, response) {
                 $.ajax({
                     url: "index.php?option=com_fmw&view=keywords_api&controller=keywords_api&format=raw", 
                     type: "GET", dataType: "json",
                     data: { expr: request.term},
                     sucess: function (data) {
                         response($.map(data, function (item) {
                             return item.value;
                         }))
                     }
                 })
                 }, 
     minChars: 1,
     dataType: 'json'
};

$( "#search_box_input" ).autocomplete(acOptions);

I get the following response from the server:

[{"value":"Greater"},{"value":"great"},{"value":"greatly"},{"value":"Greater-Axe"}]

However, the autocomplete field is not showing results, even though I can see that the ajax request got sent and that the server answered. What am I doing wrong?

1条回答
你好瞎i
2楼-- · 2019-07-08 21:55

sucess is spelt wrong. Try success instead.

success: function (data) {
    response($.map(data, function (item) {
        return item.value;
    }))
}
查看更多
登录 后发表回答