【发布时间】:2016-05-06 07:21:27
【问题描述】:
我想将 json 数据从外部文件传递给 jstree 对象。 我有关注 sn-p 但它不起作用
<script>
$.jstree.defaults.core.themes.responsive = true;
$('#frmt').jstree({
plugins: ["checkbox", "types"],
"json_data":{
"ajax" : {
"url" : "D:\p\web\nodes.json" // the URL to fetch the data. Use relative url if required
}
},
"types": {
"file": {
"icon": "jstree-file"
}
}
});
</script>
我的nodes.json 文件
[
{
"id": "ajson1",
"parent": "#",
"text": "Simple root node"
},
{
"id": "ajson2",
"parent": "#",
"text": "Root node 2"
}, {
"id": "ajson3",
"parent": "ajson2",
"text": "Child 1"
}, {
"id": "ajson4",
"parent": "ajson2",
"text": "Child 2"
}
]
当我在 javascript 中手动插入这些数据时,它可以正常工作,但是当我分配 nodes.json 外部文件的路径时,它就不起作用了
【问题讨论】:
标签: javascript json jstree