`table.ajax.reload()` won't work

`table.ajax.reload()` won't work

abhijitghateabhijitghate Posts: 3Questions: 2Answers: 0
edited April 2018 in Free community support

I am having a input field on my front end where I accept a code which is used to fetch data from the backend and display it in datatable. I am making a ajax call to bring that data to the front. But when I change the value in the input field (and try to update data in datatable using table.ajax.reload()) , the ajax call by the datatable holds on to older code. So the table wont get updated. Please help.


"ajax" : { url : "/my/url", dataSrc:"",` data:{'form':$("#my_id").serialize() , 'csrfmiddlewaretoken':csrf_token}, contentType : "application/json", complete: function(data){ $(".overlay").hide(); }, success: function(){ console.log("ajax successful"); } },

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    Hi @abhijitghate ,

    I think the problem is because the data option for your input cell is being read at table initialisation, and not dynamically. If you make it a function, as in the sixth example on the ajax page, it will read the current value.

    I hope that helps,

    Cheers,

    Colin

  • abhijitghateabhijitghate Posts: 3Questions: 2Answers: 0

    Thanks Colin!

    It sure worked!! :) :)

    Cheers!!
    Abhijit

This discussion has been closed.