reload table with ajax.url().load not working
reload table with ajax.url().load not working
coderman1
Posts: 6Questions: 1Answers: 0
function status_changed()
{
var value = document.getElementById("campaign_status").value;
var table = $('#example').DataTable();
var url = "../json/json.get_campaigns.php?filter=" + value;
table.ajax.url(url).load();
}
$(document).ready(function()
{
var table = $('#example').DataTable( {
"fnServerData": function ( sSource, aoData, fnCallback ) {
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
},
"sAjaxSource": "../json/json.get_campaigns.php?filter=Active",
...}
What I am basically trying to do is update the contents of a table based on the selected value in a combo box. I am trying to get it to reissue the json call with the new supplied url, but I can see in the chrome debugger that ajax.url(url) is not actually requesting the new URL, it is requesting the one thats defined in sAjaxSource.
Am I doing this the right way?
This discussion has been closed.
Answers
you could do it like this
and then call the reload function every time the selection is changed.
Datatables will fun the 'Data' function each time and get the new value.
I'd suggest doing it the way @larsonator says. having said that, your own method should work, and if you could link to a test case showing the issue I'll debug what is going wrong.
Allan