开发者

jQuery Autocomplete JSON response

开发者 https://www.devze.com 2023-01-14 05:39 出处:网络
I am trying to use the jQueryUI autocomplete plugin but I am unable to make it work. I am using Spring MVC at the backend and I am returning JSON response by following this this post that I got from

I am trying to use the jQueryUI autocomplete plugin but I am unable to make it work.

I am using Spring MVC at the backend and I am returning JSON response by following this this post that I got from the net.

My problem is, ther开发者_如何学Ce seem to be some problem in the way the autocomplete plugin expects the JSON response. I checked on my firebug and it is displaying below JSON response.

{"data":["TEST-01","TEST-02","TEST-03"]}

No error is being thrown, but the autocomplete is not suggesting anything.


Why don't you consult official jquery-ui documentation about expected response format?

In short, valid response could look like this

[{'label': 'TEST-01'}, {'label': 'TEST-02'}, {'label': 'TEST-03'}]

More from the docs
data can be a simple Array of Strings, or it contains Objects for each item in the array, with either a label or value property or both. The label property is displayed in the suggestion menu. The value will be inserted into the input element after the user selected something from the menu. If just one property is specified, it will be used for both, eg. if you provide only value-properties, the value will also be used as the label.

0

精彩评论

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