Jquery 在EasyUI Combobox中使用Ajax加载数据

Jquery 在EasyUI Combobox中使用Ajax加载数据,jquery,ajax,json,combobox,jquery-easyui,Jquery,Ajax,Json,Combobox,Jquery Easyui,如何在EasyUI combobox中使用ajax加载json数据 $('#cc').combobox({ valueField: 'id', textField: 'text', data: function (request, response) { $.ajax({ url: '@Url.Action("GetBranchesByCustomer","WidgetFeatures

如何在EasyUI combobox中使用ajax加载json数据

    $('#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 };
                    }))

                }
            })
        }
    });
我试过这个脚本,但没有成功。我的错在哪里

尽管我添加了如下所示的“id”参数,但此脚本给了我以下错误:uncaughttypeerror:无法读取未定义的属性“id”

<input id="cc" name="dept" value="aa">

我解决了这个问题。加载json数据不需要ajax。因为已经有“GetBranchesByCustomer”方法返回json数据。脚本如下:

  $('#cc').combobox({
    valueField: 'id',
    textField: 'text',
    url: '@Url.Action("GetBranchesByCustomer","WidgetFeatures")'
});
尝试将
response($.map(数据,函数(项){
更改为
response($.map(数据,函数(项){
)。