jQuery Autocomplete order of results

前端 未结 3 2135
无人共我
无人共我 2021-02-14 08:34

I am using the jQuery-autocomplete plugin to get suggestions for completion of the input string using an AJAX call to a server. Also, the server takes care of returning the resu

3条回答
  •  日久生厌
    2021-02-14 09:32

    Since there's no sortResults options in current build of jQuery Autocomplete plugin, I had to search another solution to this problem and found out the only reason the plugin is sorting result is that server response is being normalized everytime it's not a pure array with objects {label: ..., value: ...}.

    Considering PHP as a language of your use, json_encode(array_values($your_array)); should do the trick.

提交回复
热议问题