javascript - 将 JSON 从 JStree 发送到 MSSQL DB

标签 javascript html json asp.net-web-api2 jstree

我可以通过 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/

相关文章:

javascript - tsc tsconfig.json 设置编译为与 requirejs 兼容的 JS 类?

javascript - 选择时将箭头移动到每个菜单

SVG 文档中的 HTML 按钮

php - 使用 PDO 从 MySQL 获取数据

javascript - node.js:需要 json 文件返回 MODULE NOT FOUND

python - 类型错误 : the JSON object must be str, 不是 'Response' 与 Python 3.4

javascript - animate.css 的自定义函数导致问题

javascript - 有灰度JPG格式吗?

jquery - 创建一个选定的选项卡链接

html - 在 CSS 文件中设置输入框颜色设置