1
我正在使用自動完成jquery json,但它沒有顯示結果。 有以下代碼我正在使用。Jquery自動完成不顯示數據
$(function() {
$("#course").autocomplete({
source: function(request, response) {
$.ajax({
url: "ajax.php",
dataType: "json",
data: {
style: "full",
maxRows: 20,
name_startsWith: request.term
},
success: function(data) {
response($.map(data.geonames, function(item) {
return {
Id: item.Id + (item.FirstName ? ", " + item.LastName : "") + ", " + item.Email,
value: item.Id
}
}));
}
});
},
minLength: 2,
select: function(event, ui) {
log(ui.item ?
"Selected: " + ui.item.label :
"Nothing selected, input was " + this.value);
},
open: function() {
$(this).removeClass("ui-corner-all").addClass("ui-corner-top");
},
close: function() {
$(this).removeClass("ui-corner-top").addClass("ui-corner-all");
}
});
});
</script>
以這種格式生成Ajax文件。
[{"Email":"[email protected]","FirstName":"Sobha","Id":12333,"LastName":"Marati"}]