使用https://github.com/dabeng/OrgChart如何在ajax调用中设置请求头
我尝试了以下几种方法
$('#chart-container').orgchart({
'data' : '/api/v1/profiles/orgchart/',
'beforeSend': function(xhr){xhr.setRequestHeader('X-CSRF-TOKEN', token);},
'nodeContent': 'account_firstname'
});但这并不管用
发布于 2017-11-06 17:36:22
为什么不使用ajax获取json数据源,然后根据ajax请求使用获取的数据源创建组织结构图。
$.ajax({
'url': '/api/v1/profiles/orgchart/',
'beforeSend': function(xhr){xhr.setRequestHeader('X-CSRF-TOKEN', token);},
})
.done(function( data ) {
$('#chart-container').orgchart({
'data' : data
'nodeContent': 'account_firstname'
});
});https://stackoverflow.com/questions/46457604
复制相似问题