Server side not receiving ajax parameters

Server side not receiving ajax parameters

sajjad217sajjad217 Posts: 1Questions: 1Answers: 0
edited December 2023 in Free community support

# Client side code:

            $('#dataTable').dataTable({
                            dom: "rtiplf",
                            stripeClasses: [],
                            responsive: true,
                            processing: true,
                            destroy: true,
                            searching: false,
                            ordering: false,
                            language: {
                                processing: '<i class="fa fa-spinner fa-spin fa-3x fa-fw"></i><span class="sr-only">Loading...</span>'
                            },
                            serverSide: true,
                            displayLength: 10,
                            pagingType: "simple_numbers",
                            order: [[0, "desc"]],
                            ajax: {
                                url: "/AllView/GetReport",
                                type: 'POST',
                                dataType: "json",
                                data: function (d) {
                                    d.addActionButton = "2";
                                },
                            },
                        });
                    }

# Server side code:

            [HttpPost]
            public async Task<JsonResult> GetReport(int draw, int start, int length,
                string addActionButton)
            {
              //other codes
            }

The problem is: I am getting Draw = 0, start = 0, length = 0, addActionButton = "" on server side when there is more than 169 columns in my table. otherwise everything is working fine.

Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide

Answers

  • kthorngrenkthorngren Posts: 21,449Questions: 26Answers: 4,975

    I'm not familiar with your server side code language but you can verify what is being sent to the server by using the browser's network inspector. In Chrome look at the Payload tab to see the sent parameters.

    Datatables does not send draw = 0. It always starts with draw = 1 then increments from there. That and the addActionButton = "" suggests that the server script is not parsing the POST parameters and defaulting to 0 or "".

    Kevin

Sign In or Register to comment.