Serverside, localStorage, reload ajax withs params

Serverside, localStorage, reload ajax withs params

ketnaketna Posts: 8Questions: 4Answers: 0
edited April 2022 in Free community support

Hi, I have a problem with ajax reload with params. Ajax returns correct data however table does not refresh. I have tested all found solutions and none seems to work. Any help would be appreciated.

xTable = $("#xList").DataTable({
  dom:
    "<'row submenu3'<'col-sm-6'B><'col-sm-4'i><'col-sm-2'p>>" +
    "<'row tabtable3'<'col-sm-12'tr>>",
  order: [[1, "desc"]],
  orderCellsTop: true,
  fixedHeader: true,
  pageLength: 50,
  paging: true,
  rowId: "id",
  scrollX: true,
  scrollY: getheight(140) + "px",
  lengthMenu: [
    [15, 30, -1],
    [15, 30, "All"],
  ],
  serverSide: true,
  ajax: {
    type: "POST",
    url: "all.php",
    data: function (d) {
      return $.extend({}, d, {
        token: $('meta[name="token"]').attr("value"),
        start: localStorage.getItem("srv_startdate"),
        end: localStorage.getItem("srv_enddate"),
        filters: localStorage.getItem("srv_filters"),
      });
    },
  },
});

$("#flDateRange").on("apply.daterangepicker", function (ev, picker) {
  $("#xList").DataTable().ajax.reload();
});

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

Answers

  • allanallan Posts: 63,237Questions: 1Answers: 10,418 Site admin

    That suggests to me that all.php isn't returning the data that DataTables expects.

    I'm happy to take a look at a test case showing the issue.

    Allan

  • ketnaketna Posts: 8Questions: 4Answers: 0

    It was draw param in server response.
    Used md5(uniqid(rand(), true));
    Cheers.

Sign In or Register to comment.