我正在尝试使用以下 JSON 数据在递归内部函数中创建以下类似结构,但运气不佳,确实需要一些帮助,所以如果有人可以提供帮助,请做。先感谢您
代码(编辑):
$('#citytree').html('');
$.ajax({
type: "POST",
url: base_url+"Cprivileges/checkbox",
data: dataString,
dataType: "json",
cache: false,
beforeSend: function(){$('#ajax_loading').show();},
complete:function(){$('#ajax_loading').hide();},
success: function(data){
chebox = "<ul>";
$.each(data.cuy, function(i,cuy){
chebox = chebox + "<li><input type='checkbox' value=" + cuy.idmenu + " name='mk[]'>" + cuy.Title + "</li>";
});
chebox = chebox + "</ul>";
$("#citytree").append(chebox);
}
});
JSON:
{
"cuy": [{
"idmenu": "1",
"IDparent": "0",
"Title": "Data Aktifitas Supporting"
}, {
"idmenu": "2",
"IDparent": "1",
"Title": "Sumber Daya Manusia"
}, {
"idmenu": "3",
"IDparent": "0",
"Title": "Ratio Keuangan"
}, {
"idmenu": "4",
"IDparent": "3",
"Title": "Beban Resiko Operasional"
}, {
"idmenu": "5",
"IDparent": "3",
"Title": "Business Plan"
}]
}
如何生成这个:
- 数据活动支持
- 桑巴达亚马努西亚
- 比率 Keuangan
- Beban Resiko 运营
- 商业计划书