Server side processing issue
Server side processing issue
Hydroooo
Posts: 2Questions: 1Answers: 0
Hello
Since the 2.0.1 update my server side processing DataTables are not working anymore, i'm having this error in console :
dataTables.min.js:4 Uncaught TypeError: e.apply is not a function
at dataTables.min.js:4:43321
at Array.map (<anonymous>)
at ee (dataTables.min.js:4:43296)
at ve (dataTables.min.js:4:21718)
at S (dataTables.min.js:4:24997)
at dataTables.min.js:4:24849
at Object.t [as success] (dataTables.min.js:4:29938)
at i (jquery.min.js:2:28017)
at Object.fireWith [as resolveWith] (jquery.min.js:2:28783)
at A (jquery.min.js:4:14035)
I did not change anything except the DataTables JS scripts (using 2.0.1).
Here's my Javascript options on my datatables :
var optionsTest= {
serverSide: true,
ajax: '../ajax/test/datatable_test.php',
processing: true,
columns: [
{ "data": "action_log" },
{ "data": "date_log" },
{ "data": "requete_log" },
{ "data": "id_user_log" },
{ "data": "ip_user_log" },
{ "data": "navigateur_os_log" },
{ "data": "page_script_exec_log" },
{ "data": "page_script_precedent_log" },
{ "data": "error_info" },
],
};
And my PHP :
// Array of database columns which should be read and sent back to DataTables.
$columns = array(
array('db' => 'id_log', 'dt' => 'id_log'),
array('db' => 'execution_requete_log', 'dt' => 'execution_requete_log'),
array(
'db' => 'action_log',
'dt' => 'action_log',
'formatter' => function( $d , $row) {
if($row['execution_requete_log'] === 'Réussie') {
return '<span class="badge badge rounded-pill badge-subtle-success">'.$d.'<span class="ms-1 fas fa-check"></span></span>';
} else {
return '<span class="badge badge rounded-pill badge-subtle-danger">'.$d.'<span class="ms-1 fas fa-times"></span></span>';
}
}
),
array(
'db' => 'date_log',
'dt' => 'date_log',
'formatter' => function( $d ) {
return date( 'd/m/Y H:i:s', strtotime($d));
}
),
array(
'db' => 'requete_log',
'dt' => 'requete_log',
'formatter' => function( $d, $row) {
// On utilise substr pour ne tout afficher
// On fait un a href qui ouvre ouvreModalRequeteLog avec comme paramètre $id_log
$id_log = $row['id_log'];
return '<a href="#" onclick="ouvreModalRequeteLog(\'' . $id_log . '\', \'' . URL_APPLI . '\')">' . substr($d, 0, 30) . '...</a>';
}
),
array('db' => 'id_user_log',
'dt' => 'id_user_log',
'formatter' => function( $d ) {
$prenom_nom = $utilisateur->getPrenom() . ' ' . $utilisateur->getNom();
return $prenom_nom;
}
),
array('db' => 'ip_user_log', 'dt' => 'ip_user_log'),
array('db' => 'navigateur_os_log', 'dt' => 'navigateur_os_log'),
array('db' => 'page_script_exec_log', 'dt' => 'page_script_exec_log'),
array('db' => 'page_script_precedent_log', 'dt' => 'page_script_precedent_log'),
array(
'db' => 'error_info',
'dt' => 'error_info',
'formatter' => function( $d ) {
return '<span class="text-danger-emphasis">'.$d.'</span>';
}
),
);
If I go back to old version, it works fine.
Thank you for any possible help !
This question has an accepted answers - jump to answer
Answers
No test case provided, so I can't debug it unfortunately. The example for server-side processing is working okay, so there is something about the versions or code on your page that is causing the issue, which I would need a test case to be able to debug. That's why I explicitly ask for one in the forum rules and in the template text for a new post, which has been deleted here.
My guess is that an old version of Select is being used - I've seen that error with Select before. But it might be that, it might not, you might not even be using Select - I honestly don't know.
Please link to a test case showing the issue so I can offer some help
Allan
Hello allan, I apologize for not providing a test case.
However, I am not sure how to do it using https://live.datatables.net/ when using a server side ?
I would like to thank you, your guess was completely right - I was using an old version of Select (only one I did not change), now it works completely fine.
Thanks again.
Good to hear you've got it working.
This example can be used as a template to provide test cases in future.
Allan
Spent a day and a half trying to figure it why datatables were not working in all the app since the update until I found this post, now they are working, you both saved my day..
Ty!