我可以通过 ASP.net api Controller 将数据从 MSSQL 表加载到 JStree。但是我无法通过 ASP.net Web api Controller 将 JSON 对象发送到 MSSQL 数据库。
下面显示我的脚本代码``
<script>
$(function () {
$('#html1').jstree({
'core': {
'animation': 0,
'check_callback': true,
'data': {
//'url': '/Home/Nodes',
'type': 'POST',
'url': apiBaseUrl + '/api/GenNode/Nodes',
'data': function (node) {
return { 'id': node.id };
}
}
},
"plugins": ["themes", "html_data", "ui", "crrm", "contextmenu", 'dnd', 'state'],
}).on('rename_node.jstree', function (e, data) {
}).on('create_node.jstree', function (e, data) {
}).on('delete_node.jstree', function (e, data) {
}).jstree();
});
</script>
下面的html代码
<div id="html1"> </div>
最佳答案
您需要从 JS Tree 事件处理程序对服务器进行 Ajax 调用,以将数据发布到服务器..
}).on('rename_node.jstree', function (e, data) {
// ajax call
}).on('create_node.jstree', function (e, data) {
// ajax call
}).on('delete_node.jstree', function (e, data) {
// ajax call
}).jstree();
关于javascript - 将 JSON 从 JStree 发送到 MSSQL DB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42694625/