相关疑难解决方法(0)

jstree:未捕获的TypeError:无法读取未定义的属性“子级”

在我的服务器中,我以jsTree的格式返回JSON对象:

{"id":"value", "text":"value", "parent":"value"} 
Run Code Online (Sandbox Code Playgroud)

我通过Ajax调用获得了它。Console.log向我显示了详细信息,但是jsTree给了我错误:

未捕获的TypeError:无法读取未定义的属性“子级”

视图:

$.ajax({
    url: "/category",
    dataType: 'json',
    type: 'GET',
    success: function (res) {
        $.each(res, function (i, obj) {
            products.push([obj.id, obj.parent, obj.text]);
            $('#jstree_demo_div').jstree({
                'core': {
                    'data': [{ "id": obj.id, "parent": obj.parent != 0 ? obj.parent : "#", "text": obj.text }]
                }
            });
            console.log(obj.parent != 0 ? obj.parent : "#");
        });

    }
});
Run Code Online (Sandbox Code Playgroud)

javascript ajax jquery jstree jstree-search

5
推荐指数
1
解决办法
7563
查看次数

标签 统计

ajax ×1

javascript ×1

jquery ×1

jstree ×1

jstree-search ×1