我遇到自动完成和jquery问题。 网页返回以下数组:
[{'id':'test','value':'test'},{'id':'test','value':'test2'}]
包含jquery代码的页面包含以下代码段:
<script type="text/javascript" src="js/jquery-1.8.3.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.9.2.custom.js"></script>
<input type="text" id="field" />
<script>
$(function() {
$("#field").autocomplete({source: "http://localhost/richieste/mypage.asp"});
});
</script>
阵列中可能有什么问题吗?
编辑:与我写的相反,该页面未在服务器上调用。我试过了两个
$("#field").autocomplete({source: "http://localhost/richieste/mypage.asp"});
和
$("#field").autocomplete({source: "mypage.asp"});
由于
答案 0 :(得分:0)
使用不同的ID,尝试:
$("#field").autocomplete({
source: "http://localhost/richieste/mypage.asp"
}).data("autocomplete")._renderItem = (function (ul, item) {
return $("<li></li>")
.data("item.autocomplete", item)
.append("<a>" + item.value + "</a>")
.appendTo(ul);
});
演示:: jsFiddle