How can I load json datas with ajax in EasyUI combobox?
$('#cc').combobox({
valueField: 'id',
textField: 'text',
data: function (request, response) {
$.ajax({
url: '@Url.Action("GetBranchesByCustomer","WidgetFeatures")',
type: "POST",
dataType: "json",
data: { term: request.term },
success: function (data) {
response($.map(data, function (item) {
return { id: item.id, text: item.name };
}))
}
})
}
});
I tried this script, but it didn't work. Where is my mistake?
Although I add "id" parameter like below, this script gives me this error: Uncaught TypeError: Cannot read property 'id' of undefined
<input id="cc" name="dept" value="aa">
I solved the problem. It doesnt need ajax for load json datas. Because already "GetBranchesByCustomer" method returns json data. Scripts are below :