Datatables ajax reload with updated data to ajax call

Datatables ajax reload with updated data to ajax call

morganrobmorganrob Posts: 18Questions: 7Answers: 2

I have an ajax-sourced datatable where the ajax call requires data which works fine:

var curCust = { customer: "TEST", refNo: "D" };
var pickup = $("#pickup").DataTable({
            ajax: {url:"api/pickups/", dataSrc:'', data:curCust},
            columns: ....

Now, how do I reload that with new request data? I believe once the datatable is created the ajax:{data: is fixed, and

pickup.ajax.reload();

doesn't reflect the current values in my curCust object. What am I missing?

Thanks, Rob

This question has an accepted answers - jump to answer

Answers

  • morganrobmorganrob Posts: 18Questions: 7Answers: 2
    Answer ✓

    Nevermind!

    var pickup = $("#pickup").DataTable({
                ajax: {
                    url: "api/pickups/", dataSrc: '', data: function (d) { return curCust; }
                },
    
  • allanallan Posts: 63,350Questions: 1Answers: 10,443 Site admin

    Thanks for posting back - good to hear you have it working now!

    Allan

  • smo_usersmo_user Posts: 8Questions: 1Answers: 1

    Very useful indeed...
    Thanks!

This discussion has been closed.