开发者

How to pass json data to ui autocomplete

Can anyone help me with this issue. I use jquery UI autocomplete plugin. Is there a way to pass json data like this

[{'开发者_开发问答username' : 'user1}, {'username' : 'user2}, {'username' : 'user3}]


You'll need to create an array of usernames. With jQuery, you could do the following:

var jsonData = [{'username' : 'user1'}, {'username' : 'user2'}, {'username' : 'user3'}];
var usernames = $.map(jsonData, function (obj) { return obj.username; });

$("#myInput").autocomplete({source: usernames});


Surely the documentation for the plugin must state something about this, however your question is vague at best. Which plugin are you using? Does it have any service methods to put data into?


Check out the source option in the Documentation. It can be a local JavaScript array.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜