我怎么能将ajax json结果重新加载到datatable?

时间:2022-12-24 14:25:50
$("#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);
                    }
                });

            });

This is the button event. When I click a button, it submits a form and returns a json result from controller. My goal here is to grab the result and reload my data table. I've tried FnReload(response). This one gives me a server not responded error. I've also tried FnReloadAjax(). I got syntax error. Below is the code for my table. Can anyone help plz? Thank you.

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

 $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>";
                        }
                    }
                ]
            }
        );

1 个解决方案

#1


0  

$("#save").click(function () {

            $table.fnReload("<%:Url.Action("Test")%>?"+$("#SearchTerm").serialize());



                });

The best alternative! Problem solved!

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

#1


0  

$("#save").click(function () {

            $table.fnReload("<%:Url.Action("Test")%>?"+$("#SearchTerm").serialize());



                });

The best alternative! Problem solved!

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