我如何重新加载ajax json结果到datatable

How could I reload ajax json result to datatable?

本文关键字:结果 datatable json ajax 何重新 加载      更新时间:2023-09-26
$("#save").click(function () {
            $.ajax({
                url: "<%:Url.Action("ApplicantSearch")%>",
                data: $("#SearchTerm").serialize(),
                type: 'POST',
                    success: function (response) {
                        alert(response.FIRST_NAME);
                        $table.fnReload(response);
                    },
                    error: function (xhr, status, error) {
                        alert(error);
                    }
                });
            });

这是按钮事件。当我单击一个按钮时,它会提交一个表单并从控制器返回一个json结果。这里我的目标是获取结果并重新加载数据表。我试过FnReload(响应)。这给了我一个服务器未响应的错误。我也尝试过FnReloadAjax()。我有语法错误。下面是我的表的代码。有人能帮忙吗?谢谢你。

 $table = $("#MasterTable").dataTable(
            {
                bAutoWidth: false,
                bProcessing: true,
                sDom: '<"$grid-toolbar"sF>tr<"dataTables-footer"ilp>',
                sSelectionMode: 'single',
                iDisplayLength: 10,

                aoColumns: [
                    {
                        sProperty: "EMP_ID",
                        sTitle: "Parent ID",
                    },
                     {
                         sProperty: "LAST_NAME",
                         sTitle: "Last Name"
                     },
                    {
                        sProperty: "FIRST_NAME",
                        sTitle: "First Name"
                    },
                    {
                        sTitle: "Maintenance Actions",
                        mRender: function (data, type, obj) {
                            return "<a href='#'>Application</a> </br>" +
                                "<a href='#'>Documents<a>  </br>" +
                                "<a href='#'>Interviews</a>  </br>" +
                                "<a href='#'>Personal Info</a>  </br>" +
                                "<a href='#'>Scores/Awards</a>  </br>";
                        }
                    }
                ]
            }
        );
$("#save").click(function () {
            $table.fnReload("<%:Url.Action("Test")%>?"+$("#SearchTerm").serialize());

                });

最好的选择!问题解决了!