Hello i wanted to make a plugin with DataTable integration but i have a problem on calling ajax in url. this is my plugin directory look like.
- in index.php i use admin_enqueue_scripts for datatable CDN.
- page_handler.php handle page html.
- cdt.js where my customize js & jquery.
usually in DataTable if we don't use WordPress, u can use url:"datatables/tasklist.php"
to call the custom php file with json encoded data but in WordPress you must use admin-ajax.php?action=my_custom_json
in order to call ajax.
cdt.js
jQuery(document).ready(function() {
var tasklist_table = jQuery('#tasklist_table').DataTable({
"lengthChange": false,
"autoWidth": false,
"searching": true,
"ordering": false,
"processing":true,
"serverSide":true,
"order":[],
"ajax":{
url:"admin-ajax.php?action=tasklist_dt",
type:"POST"
},
"columnDefs":[
{
"targets":[0],
"orderable":false,
},
],
});
});
I hope someone will help me on how to properly call the seperated php file when using ajax.