jsonTree();
function jsonTree(){ console.log("jsonTree is begin") $.getJSON(ctx+"/node/treeNodesJson.js",function(json){ console.log("json data") console.log(json) }) console.log("jsonTree is end") }
XHR 中显示json数据的文件也已经加载,但是回调函数就是不执行
最后发现是json的数据格式不正确--必须严格遵守json格式要求
var zNodes =[//不能写等号前的东西 {id:5,pId:0,name:"组合功能 演示",open:false},{id:501,pId:5,name:"冻结根节点",file:"super/oneroot"},{id:502,name:"单击展开/折叠节点",file:"super/oneclick"},{id:503,name:"保持展开单一路径",file:"super/singlepath"},{id:504,name:"添加 自定义控件",file:"super/diydom"},{id:505,name:"checkBox / radio 共存",file:"super/checkBox_radio"},{id:506,name:"左侧菜单",file:"super/left_menu","children":[ {"id":513,"name":"资源1","num":0,"open":false,"pId":1},{"id":514,"name":"资源2",//这里的逗号不能有 ] },{id:513,name:"OutLook 样式的左侧菜单",file:"super/left_menuForOutLook"},{id:507,name:"下拉菜单",file:"super/select_menu"},//不能有逗号 ];//不能有分号
1.json必须是对象或者数组
2.不能有多余的东西,严格的json格式
3.id、pid、name等必须加双引号