gpt4 book ai didi

javascript - 尝试使用 ajax 加载 getorgchart 时出错

转载 作者:行者123 更新时间:2023-11-30 20:43:33 27 4
gpt4 key购买 nike

我正在尝试使用 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 响应上。查看每个 block 的末尾:它应该有一个逗号 (,) 分隔每个 block 。试试这个回应:

{ 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" }

关于javascript - 尝试使用 ajax 加载 getorgchart 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48978421/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com