0
我在視圖上使用幾個jQuery自動完成功能來檢索CustomerName和CustomerID。jquery自動完成返回值
$(document).ready(function() {
$('#CustomerByName').autocomplete({
source: function (request, response) {
$.ajax({
url: "/Cases/FindByName",
type: "GET",
dataType: "json",
data: {
searchText: request.term,
maxResults: 10
},
contentType: "application/json; charset=utf-8",
success: function (data) {
response($.map(data, function (item) {
return {
label: item.CustomerName,
value: item.CustomerName,
id: item.CustomerID
}
}));
}
});
},
minLength: 1,
select: function (event, ui) {
$('#CustomerID').val(ui.item.id);
},
});
});
成功響應給了我標籤,值,id。有什麼方法可以訪問JSON數據中的其他字段返回?在這種情況下,整個表格將作爲json返回。
感謝
你有標籤,沒有必要將它們添加到標題。 – gdoron
感謝您的回答。我不明白你的意思。我是jquery的新手。 – Ryan