Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 尝试使用ajax加载getorgchart时出错_Javascript_Asp.net Mvc_Getorgchart - Fatal编程技术网

Javascript 尝试使用ajax加载getorgchart时出错

Javascript 尝试使用ajax加载getorgchart时出错,javascript,asp.net-mvc,getorgchart,Javascript,Asp.net Mvc,Getorgchart,我试图使用loadFromJSON加载getorgchart,但收到以下消息:“无法读取未定义的属性‘children’”。这是我的密码: var peopleElement = document.getElementById("people"); var orgChart = new getOrgChart(peopleElement, { primaryFields: ["name", "title", "phone", "mail"], ex

我试图使用loadFromJSON加载getorgchart,但收到以下消息:“无法读取未定义的属性‘children’”。这是我的密码:

    var peopleElement = document.getElementById("people");
    var orgChart = new getOrgChart(peopleElement, {
        primaryFields: ["name", "title", "phone", "mail"],
        expandToLevel: 100,
        layout: getOrgChart.MIXED_HIERARCHY_RIGHT_LINKS
    });

    $.ajax({
        contentType: 'application/json; charset=utf-8',
        dataType: 'json',
        type: 'POST',
        url: '@Url.Action("deptosGetOrg", "Deptos")',
        success: function (data) {
            var model = JSON.stringify({ 'dataSource': data })
            orgChart.loadFromJSON(model, true);
        }

    });
以下是ajax请求的结果:

{ id = "58", parentId = null, name = "DIRECCION GENERAL", title = "  ,", mail = "correo@dominio.com" }  
{ id = "59", parentId = "58", name = "DIRECCION GENERAL ASISTENTE", title = "AP AM ,Nombre", mail = "correo@dominio.com" }  
{ id = "60", parentId = "58", name = "DIRECCION DE AUDITORIA INTERNA CORPORATIVA REGIONA", title = "  ,", mail = "correo@dominio.com" } 
{ id = "61", parentId = "58", name = "DIRECCION COMERCIAL DE PAIS", title = "  ,", mail = "correo@dominio.com" }    
{ id = "62", parentId = "58", name = "DIRECCION DE COMPRAS Y LOGISTICA REGIONAL", title = "  ,", mail = "correo@dominio.com" }  
{ id = "63", parentId = "58", name = "DIRECCION DE FINANZAS REGIONAL", title = "AP AM ,Nombre", mail = "correo@dominio.com" }   
{ id = "64", parentId = "58", name = "DIRECCION JURIDICA REGIONAL", title = "  ,", mail = "correo@dominio.com" }    
{ id = "65", parentId = "58", name = "DIRECCION DE SISTEMAS REGIONAL", title = "  ,", mail = "correo@dominio.com" } 
{ id = "66", parentId = "58", name = "DIRECCION DE SERVICIO AL CLIENTE REGIONAL", title = "  ,", mail = "correo@dominio.com" }  
{ id = "67", parentId = "58", name = "DIRECCION DE INGENIERIA Y OPERACIONES REGIONAL", title = "  ,", mail = "correo@dominio.com" } 
{ id = "68", parentId = "58", name = "DIRECCION DE MERCADEO Y COMERCIAL CENTRO AMERICA", title = "  ,", mail = "correo@dominio.com" }   
{ id = "69", parentId = "58", name = "DIRECCION PROYECTOS Y TECNOLOGIA REGIONAL", title = "  ,", mail = "correo@dominio.com" }  
{ id = "70", parentId = "58", name = "DIRECCION REC.HUMANOS/REGULACION INTERCON.REGIONAL", title = "  ,", mail = "correo@dominio.com" } 
{ id = "71", parentId = "58", name = "DIRECCION COMERCIAL SVA REGIONAL", title = "  ,", mail = "correo@dominio.com" }   
{ id = "72", parentId = "58", name = "DIRECCION VENTAS MERCADO CORPORATIVO", title = "  ,", mail = "correo@dominio.com" }   
{ id = "76", parentId = "59", name = "GERENCIA DE TIENDAS PROPIAS", title = "AP AM ,Nombre", mail = "correo@dominio.com" }  
{ id = "77", parentId = "59", name = "GERENCIA FINANCIERA", title = "AP AM ,Nombre", mail = "correo@dominio.com" }  
{ id = "79", parentId = "60", name = "GERENCIA DE ASEGURAMIENTO DE INGRESOS", title = "  ,", mail = "correo@dominio.com" }  
{ id = "80", parentId = "60", name = "GERENCIA DE AUDITORIA INTERNA", title = "xxxxxxxxxxxxxxxx", mail = "xxxx@dominio.com" }   
{ id = "81", parentId = "60", name = "GERENCIA DE ANALISIS Y RIESGO REGIONAL", title = "xxxxxxxxxxxxxxx", mail = "xxxx@dominio.com" }   
{ id = "82", parentId = "61", name = "GERENCIA DE ESTRATEGIA COMERCIAL", title = "xxxxxxxxxxxx", mail = "xxxx@dominio.com" }    
{ id = "83", parentId = "61", name = "GERENCIA MERCADEO/DESARROLLO COMERCIAL", title = "xxxxxxxxxxxx", mail = "xxxx@dominio.com" }  
{ id = "84", parentId = "61", name = "GERENCIA DE VENTAS INMOBILIARIAS", title = "xxxxxxxxxxxxxxxxxx", mail = "xxxx@dominio.com" }  
{ id = "85", parentId = "61", name = "GERENCIA DE OPERACIONES COMERCIALES PARA DISTRIBUI", title = "xxxxxxxxxxxxxxxxxxx", mail = "xxxxxxx@dominio.com" }    
{ id = "89", parentId = "62", name = "GERENCIA DE COMPRAS", title = "  ,", mail = "correo@dominio.com" }    
{ id = "90", parentId = "62", name = "GERENCIA DE LOGISTICA REGIONAL", title = "xxxxxx", mail = "xxxxxxx@dominio.com" } 

提前谢谢

我认为问题可能在于JSON响应。看看每个块的末尾:它应该有一个逗号(,)分隔每个块。尝试以下回答:

{ id = "58", parentId = null, name = "DIRECCION GENERAL", title = "  ,", mail = "correo@dominio.com" },
{ id = "59", parentId = "58", name = "DIRECCION GENERAL ASISTENTE", title = "AP AM ,Nombre", mail = "correo@dominio.com" }

删除第二个参数

loadFromJSON(模型)


下面是一个处理数据的示例:

Just
orgChart.loadFromJSON(数据,true)(不是
型号
)谢谢,斯蒂芬。我有完全相同的错误。在你的评论之后,我使用“dataSource”参数做了一个测试,只复制了一些记录(大约20条),一切都很好,所以我的格式还可以。然而,我试图复制yhe 600条记录,得到了“UncaughtTypeError:无法读取未定义的属性‘children’”消息。我尝试使用ajax只加载20个,但得到了相同的错误。谢谢!现在我可以看到orgchart正确显示了。然而,当我尝试从我的组织加载所有部门(几乎600个)时,它没有显示任何内容。我做了一个测试,最多200个,效果很好。组件可以显示的部门数量是否有限制?