How to have multiple server side processing table in one page

How to have multiple server side processing table in one page

luccagermanoluccagermano Posts: 1Questions: 1Answers: 0

I want to know if its able to have multiple datatables with server side processing in the same page, and i need to have the ajax call to different links so i can bring different data to the screen

for(var i = 0; i < arr_id.length; i++) {
        var id = arr_id[i];
        var table = data_js.html.table[i];
        var columns = data_js.html.columns[i];

$("#table_"+id).DataTable({
  "processing": true,
  "serverSide": true,
  "ajax": {
     url: "php/"+arquivo+".php",
     type: "POST",
     dataType: 'json',
     data: function (data) {
          data.chave = "get_"+id;
     }
  }
});
}

i saw that the id i am using on ajax it did not save the state for the DataTable function call, if i have the id of table on the ajax call will be perfect because i could its the id i use to create the table and is what i call for my function

Answers

  • kthorngrenkthorngren Posts: 21,205Questions: 26Answers: 4,927

    I suspect you will want to use a static value for the ajax.data option instead of a function. As a function the value will change each time an ajax request is sent. I think you will want this instead:

      "ajax": {
         url: "php/"+arquivo+".php",
         type: "POST",
         dataType: 'json',
         data: {
            chave:  "get_"+id;
         }
      }
    

    Kevin

Sign In or Register to comment.