Server side rendering not sending post request on each page change or search

Server side rendering not sending post request on each page change or search

greennngreennn Posts: 13Questions: 8Answers: 0

I recently switched my datatables to use server side rendering because I want to display my datatables on mobile devices and even though my laptop was working pretty fine, using datatable using client mobile devices can be pretty slow. I found out that there is some speed improvement in both my laptop and mobile device from using server side rendering but I am completely surprised because I do not see any post request being made to my server on each page change.

let tblAssignedJobs = $('#tblAssignedJobs').DataTable({
    "oLanguage": {
        "sEmptyTable": "There are no jobs assigned to you at this moment"
    },
    autoWidth  : false
    ,responsive : true
    ,deferRender    : true
    ,processing : true
    ,paging     : true
    ,pageLength : 25
    ,searching  : true
    ,info       : true
    ,ordering       : true
    ,dom            : "<ipf>"
    ,bPaginate  : false
    ,sDom       :"fptip",
    "aoColumns": [{
        "mData":"studentNumber"
      },{
        "mData": "studentType"
      }
      ,
      {
        "mData":"Description"
      }
      ,
      {
        "mData":"LocationNumber"
      }
      ,
      {
        "mData":"Address"
      },
      { "mData":"StudentNumber",
        "mRender": function(data, type, full) {

            return `<a href = '/editStudent?studentNumber=${data}'><button class='btn btn-primary'>Edit Job</button></a>`
        }  
      }
    ],
    ajax: {
        url: "assignedJobs",
        type: "POST"
    },

    responsive: true
});

On my Nodejs backend server:

       let result = await rows.query(`My Query`)

          myJSON = { 
            "iTotalRecords": result.recordset.length,
            "iTotalDisplayRecords": 25,
            "sEcho":10,
            "aaData": result.recordset
            }
            res.send(myJSON)

I have morgan enabled in my Nodejs server which logs any type of request made to my server but when I change page or search something in my datatable I do not see any post request that was sent. I was expecting a post request on each page change and each new search.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,311Questions: 26Answers: 4,948
    Answer ✓

    You need the serverSide option set to true for server side processing to be enabled. Unless I'm missing it I don't see it in your config.

    Kevin

This discussion has been closed.