数据如下:
{"zNodes":[{"id":22,"name":"龙门石窟","type":"ycd","children":[{"id":1,"name":"西山","type":"ycq","nocheck"
:"true","children":[{"id":1,"name":"奉先寺片区","type":"ycp","nocheck":"true","children":[{"id":1,"name":"
奉先寺","type":"ycdi","nocheck":"true","children":[{"id":1,"name":"山顶监测点1#","type":"cd","nocheck":"true"
},{"id":2,"name":"南壁力士雕像监测点","type":"cd","nocheck":"true"},{"id":3,"name":"南壁天王监测点","type":"cd","nocheck"
:"true"},{"id":5,"name":"山顶监测点2#","type":"cd","nocheck":"true"},{"id":7,"name":"北壁力士监测点","type":"cd"
,"nocheck":"true"},{"id":8,"name":"西壁阿南监测点","type":"cd","nocheck":"true"},{"id":9,"name":"北壁文殊菩萨监测点"
,"type":"cd","nocheck":"true"},{"id":10,"name":"北壁碑刻监测点","type":"cd","nocheck":"true"},{"id":11,"name"
:"山顶监测点3#","type":"cd","nocheck":"true"}]}]},{"id":2,"name":"万佛洞片区","type":"ycp","nocheck":"true","children"
:[{"id":2,"name":"万佛洞山顶","type":"ycdi","nocheck":"true","children":[{"id":4,"name":"山顶监测点1#","type":"cd"
,"nocheck":"true"},{"id":6,"name":"山顶监测点2#","type":"cd","nocheck":"true"}]}]}]},{"id":2,"name":"东山","type"
:"ycq","nocheck":"true","children":[]},{"id":3,"name":"32131","type":"ycq","nocheck":"true","children"
:[]}]}]}
展现效果如下:
获取后台的值是这样的,大家都知道字符串如果换行了都是要用+号才可以加起来的(比如:“ ”+“ ”),但是这个我不知道我在前端改怎么处理,我的ajax代码是这样写的,如下:
//加载左边节点树
function LoadTree() {
$.ajax({
url: rootPath + "CSPZ/ZtreeCx",
type: "post",
async: false,//将ajax异步请求改为同步请求
//dataType: "json",
success: function (data) {
//alert(data);
if (true) {
$.fn.zTree.init($("#d"), setting, (eval('(' + data + ')').zNodes));
} else {
alert("没有获取到数据")
}
}
})
}
请问给我大神,谁能告诉,我要怎么做才可以把这个字符串拼接起来,然后进行展现