Jquery Autocomplete not showing results [closed]

扶醉桌前 提交于 2019-12-24 01:07:27

问题


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:


sucess is spelt wrong. Try success instead.

success: function (data) {
    response($.map(data, function (item) {
        return item.value;
    }))
}


来源:https://stackoverflow.com/questions/5193028/jquery-autocomplete-not-showing-results

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!