Reload DataTable Serverside processing with new urlAjax
Reload DataTable Serverside processing with new urlAjax
Emyleen
Posts: 21Questions: 8Answers: 0
Hello,
I don't find in the doc how to reload my datatable with new url ajax. When I ask DataTable it does anything.
This is my code, I use jquery :
// Table init
//-------------------------------------------------
var course_list = $("#filter-course").val();
var status = $("#filter-status").val();
var paiement = $("#filter-payment .active").attr("data-key");
$("#data_table_purchases").loadDataTable("../rpc.php?p=purchases&a=ajax_get_purchases&plg=purchases&admin=1&course_list=" + course_list + "&status=" + status + "&paiement=" + paiement);
// Filters
//-------------------------------------------------
$("#filter-status, #filter-course").on("change", function(e){
var course_list = $("#filter-course").val();
var status = $("#filter-status").val();
var paiement = $("#filter-payment .active").attr("data-key");
$("#data_table_purchases").loadDataTable("../rpc.php?p=purchases&a=ajax_get_purchases&plg=purchases&admin=1&course_list=" + course_list + "&status=" + status + "&paiement=" + paiement);
});
/*
* Load the DataTable
*/
$.fn.loadDataTable = function(urlAjax){
var $datatable = $(this);
$datatable.DataTable({
"processing": true,
"serverSide": true,
"ajax": {
"url": urlAjax,
"type": 'GET'
}
...
});
}
Thank you for your help
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
To change the Ajax URL use
ajax.url()
.Allan
Thank you very much!
Sorry to ask questions whose answer is obvious but I have to admit that I often lose myself in Datatable documentation.
If I can suggest an improvement, would be to establish a clearer separation between the object "datatable" and the DataTable API because it is not clear what functions / options we can use.
Thanks again!
Yes, I think I made a mistake using both
$().dataTable()
and$().DataTable()
... The FAQs do note the difference.I would generally recommend using only `$().DataTable().
Allan