Closed barentshavet closed 4 years ago
Hi, in the official datatables doc ,it is mentioned that the function of the "draw" index is to draw the counter.
Please try to find out if the draw index exists in the ajax request.
like this:
Thanks for the quick reply. Actually, I found out the issue was CSRF.
Do you have any examples of how to send the CSRF tokens with the Ajax request?
Okay,I see. You can read CI4 User Guide - Security Class,It is the built-in security library of Codeigniter4. . You can use "csrf token ()" and "csrf hash ()" to create the CSRF certification field attached to the ajax post. Your datatables initialization code may look like this
$('#fullTable').DataTable({
"aoColumnDefs": [{
"bSortable": false,
"aTargets": [ 0,1 ]
}],
"order":[],
"serverSide":true,
"ajax":{
url:"<?=base_url('home/fullTable')?>",
type:'POST',
data : {
<?=csrf_token()?> : "<?=csrf_hash()?>"
}
}
});
In the user guide,other configurations will be explained in detail, thank you.
I tried to follow the guide and get the following error
Undefined index: draw
Not sure what the problem is?