我正在使用jQuery UI自动完成并且我正在获取结果,唯一的问题我正在获取结果
http://prntscr.com/rsm946
不确定为什么不显示,json
正确
我的JSOn
[{"name":"author","type":"U","status":"0","owner":"dbo"},{"name":"author_dates","type":"U","status":"0","owner":"dbo"}]
$("#student").autocomplete(
{
source: function(request, response) {
$.ajax({
url: "search.cfc?method=searchByName&returnformat=json",
dataType: "json",
data: {
search: request.term,
maxRows: 10
},
success: function(data) {
response($.map(data, function(item) {
return {
label: item.label, value: item.label
};
}));
}
})
},
select: function( event, ui ) {
$('#submit').css("display", "block");
}
});
最佳答案
请考虑以下几点:
$("#student").autocomplete({
source: function(request, response) {
$.getJSON("search.cfc", {
method: "searchByName",
returnformat: "json",
search: request.term,
maxRows: 10
}, function(data) {
response($.map(data, (item) => {
return $.extend(item, {
label: item.name,
value: item.name,
});
}));
});
},
select: function(event, ui) {
$('#submit').css("display", "block");
}
});
关于javascript - 使用jQuery UI自动完成但样式隐藏,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/61021617/