No JSON response while rebuilding after Post data example
No JSON response while rebuilding after Post data example
borchi
Posts: 3Questions: 1Answers: 1
Hallo,
i´m updated to Datatables 1.10.11 today. No i´m adopting my old ServerSide Post Scripts to the new version, folowing the example shown here: https://datatables.net/examples/server_side/post.html.
I got no errors and no JSON Response on my script, just fetching my simple database table.
Any ideas?
Thanks
Christian
<?php
/*
* DataTables example server-side processing script.
*
* Please note that this script is intentionally extremely simply to show how
* server-side processing can be implemented, and probably shouldn't be used as
* the basis for a large complex system. It is suitable for simple use cases as
* for learning.
*
* See http://datatables.net/usage/server-side for full details on the server-
* side processing requirements of DataTables.
*
* @license MIT - http://datatables.net/license_mit
*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Easy set variables
*/
// DB table to use
$table = 'v_b_pics';
// Table's primary key
$primaryKey = 'bid';
// 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 object
// parameter names
$columns = array(
array( 'db' => 'bname', 'dt' => 'bname' ),
array( 'db' => 'bname2', 'dt' => 'bname2' )
// array( 'db' => 'position', 'dt' => 'position' ),
// array( 'db' => 'office', 'dt' => 'office' ),
// array(
// 'db' => 'start_date',
// 'dt' => 'start_date',
// 'formatter' => function( $d, $row ) {
// return date( 'jS M y', strtotime($d));
// }
// ),
// array(
// 'db' => 'bid',
// 'dt' => 'bid',
// 'formatter' => function( $d, $row ) {
// return '$'.number_format($d);
// }
// )
);
// SQL server connection information
$sql_details = array(
'user' => 'dbuser',
'pass' => 'test',
'db' => 'test',
'host' => 'localhost'
);
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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' );
// Using the new version from 1.10.11
require( 'ssp.classnew.php' );
echo json_encode(
SSP::simple( $_POST, $sql_details, $table, $primaryKey, $columns )
);
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hallo Guys,
i found it... Just forgot to copy the ssp.class.php to the right location...
Closed :-)
Good to hear you got it working. Thanks for posting back.
Allan
Hi Allan,
it´s me again :-)
I got the same error while fetching a table with UTF-8 content. Some german äöü... I did not have in my first try.
I added UTF-8 to the datebase connection:
Now it works...