目前我有这个自动完成选项:
<script type="text/javascript">
$().ready(function () {
$("#tags").autocomplete(["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby", "python", "c", "scala", "groovy", "haskell", "pearl"], {
width: 320,
max: 4,
highlight: false,
multiple: true,
multipleSeparator: " ",
scroll: true,
scrollHeight: 300
});
});
</script>
<body> <p>
<label>Tags (local):</label>
<input type="text" id='tags' />
</p>
</body>
但我想从一个动作方法中得到这个数组:[“c++”,“java”,“php”,“coldfusion”,“javascript”,“asp”,“ruby”,“python”,“c”, “scala”、“groovy”、“haskell”、“pearl”]。例如,来自控制器“搜索”中的操作“快速搜索”。
所以是这样的:
public ActionResult QuickSearch(string term)
{
IEnumerable<string> list = test();
return Json(list, JsonRequestBehavior.AllowGet);
}
有什么建议么?