下面是我的代码:
$("#input-search").autocomplete({
source: function(request, response) {
$.get('EmployeeSearchList.igx', { name: request.term },
function(data) {
response(data.split('\n'));
}
);
}
});EmployeeSearchList.igx返回这种格式。
[{label:"JP Fortes", value:"199829"},{label:"Jeffrey Dante", value:"200507"}]作为回报,我该如何查看此内容?
<li value="199829">JP Fortes</li>
<li value="200507">Jeffrey Dante</li>发布于 2012-06-05 11:10:37
$("#input-search").autocomplete({
source: function(request, response) {
$.get('EmployeeSearchList.igx', { name: request.term },
function(data) {
var html = "";
for(var i=0; i < data.length; i++){
html += '<li value="'+data[i].value+'">'+data[i].label+'</li>';
}
$("ul").append(html);
});
}
});像这样的东西应该能起到作用。您可能需要深入研究data对象,因此只需检查返回的内容,以确保循环遍历的数组是正确的。
https://stackoverflow.com/questions/10890595
复制相似问题