繁体   English   中英

在哪里为ajax编写代码以将数据发送到服务器以保存数据表中按钮单击的操作

[英]where to code for ajax to send data to server to save action of button click in datatable

我是使用datatable插件加载ajax表的新手,我想为此操作按钮更新数据库中多行的列。 这是按钮单击的当前代码

// handle group actionsubmit button click
grid2.getTableWrapper().on('click', '.table-group-action-submit', function (e) {
    e.preventDefault();
    var action = $(".table-group-action-input", grid2.getTableWrapper());
    if (action.val() != "" && grid2.getSelectedRowsCount() > 0) {
        grid2.setAjaxParam("customActionType", "group_action");
        grid2.setAjaxParam("customActionName", action.val());
        grid2.setAjaxParam("id", grid2.getSelectedRows());
        grid2.getDataTable().fnDraw();
        grid2.clearAjaxParams();
    } else if (action.val() == "") {
        Metronic.alert({
            type: 'danger',
            icon: 'warning',
            message: 'Please select an action',
            container: grid2.getTableWrapper(),
            place: 'prepend'
        });
    } else if (grid2.getSelectedRowsCount() === 0) {
        Metronic.alert({
            type: 'danger',
            icon: 'warning',
            message: 'No record selected',
            container: grid2.getTableWrapper(),
            place: 'prepend'
        });
    }
});

在哪里编码ajax以发送grid2.setAjaxParam设置的数据

任何帮助非常感谢

提前致谢

在这里,它会从datatable从中获取数据的同一个URL到达:

if (isset($_REQUEST["customActionType"]) &&
 $_REQUEST["customActionType"] == "group_action") {
    $records["customActionStatus"] = "OK"; 
    $records["customActionMessage"] = "Group action successfully has been completed. Well done!";
  }

万一其他人需要这个,

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM