Crash in page 3, when I try to read a file trought servert-side mode
Crash in page 3, when I try to read a file trought servert-side mode
The error that I have is this one: Invalid JSON response.
My code has nothing new... just a view from mysql to list, as the example of the datatable page...
Also, If I add the line: "aaSorting" : [[0,"desc"]], in the .js file to order by date, it crash with the same error and doesn't show anything. BUT if I write: "aaSorting" : [[1, "desc"]] works, but as always... crush in the page #3
Here is my PHP code:
<?php
include_once("shared-qa/libs/config.php");
// DB table to use
$table = 'view_pagos'; // is a view in mysql
// Table's primary key
$primaryKey = 'pag_id';
// Array of database columns which should be read and sent back to DataTables.
// The `db` parameter represents the column name in the database, while the `dt`
// parameter represents the DataTables column identifier. In this case simple
// indexes
$columns = array(
array('db' => 'fecha', 'dt' => 0),
array('db' => 'fullName', 'dt' => 1),
array('db' => 'Email', 'dt' => 2),
array('db' => 'rutCliente', 'dt' => 3),
array('db' => 'SbetID', 'dt' => 4),
array('db' => 'monto', 'dt' => 5),
array('db' => 'clientCodeId', 'dt' => 6),
array('db' => 'codigoTRX', 'dt' => 7),
array('db' => 'payment', 'dt' => 8)
);
// SQL server connection information
$sql_details = array(
'user' => $DBuserSBADMIN,
'pass' => $DBpassSBADMIN,
'db' => $DBnameSBADMIN,
'host' => $DBhostSBADMIN
);
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* If you just want to use the basic configuration for DataTables with PHP
* server-side, there is no need to edit below this line.
*/
require( 'ssp.class.php' );
echo json_encode(
SSP::simple($_GET, $sql_details, $table, $primaryKey, $columns)
);
And here is my javascript code:
$('#allCreditedTrx').DataTable({
"processing": true,
"serverSide": true,
"ajax": "scripts/pagos.php?dates=" + dates,
//"aaSorting" : [[0,"desc"]],
"language": {
"decimal": "",
"thousands": ".",
},
"footerCallback": function ( row, data, start, end, display ) {
var api = this.api(), data;
// Remove the formatting to get integer data for summation
var intVal = function ( i ) {
return typeof i === 'string' ? i.replace(/[\$,.]/g, '')*1 : typeof i === 'number' ? i : 0;
};
// Total over all pages
total = api
.column(5)
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
// Total over this page
pageTotal = api
.column(5, { page: 'current'} )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
total = fn.formateaNumero(total);
pageTotal = fn.formateaNumero(pageTotal);
// Update footer
$( api.column(5).footer() ).html(
'<span style="font-size: 20px; color: green;">$' + pageTotal + '</span> <span style="font-size: 14px; color: #888;">( $'+ total +' Total)</span>'
);
}
});
Please I need help!
Replies
The first place to start is to follow the troubleshooting steps at the link provided in the alert message:
https://datatables.net/manual/tech-notes/1
What are your results from following the steps?
Kevin