Invalid JSON response.

Invalid JSON response.

ebenezzeoebenezzeo Posts: 3Questions: 1Answers: 0
edited February 2020 in Free community support

DataTables warning: table id=example - Invalid JSON response.

$table = 'products1';
 
 
$primaryKey = 'product_id';
 
 
$columns = array(
  array( 'db' => 'pname', 'dt' => 'pname' ),
    array( 'db' => 'cat',  'dt' => 'cat' ),
    array( 'db' => 'color',   'dt' => 'color' ),
    array( 'db' => 'size',     'dt' => 'size' ),
    array(
        'db'        => 'date_arrival',
        'dt'        => 'date_arrival',
        'formatter' => function( $d, $row ) {
            return date( 'jS M y', strtotime($d));
        }
    ),
    array(
        'db'        => 'price',
        'dt'        => 'price',
        'formatter' => function( $d, $row ) {
            return '$'.number_format($d);
        }
    )
);
 
// SQL server connection information
$sql_details = array(
    'user' => 'root',
    'pass' => '',
    'db'   => 'smart',
    'host' => 'localhost'
);
 
  
 
require( 'ssp.class.php' );
 
echo json_encode(
    SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns )
);

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • ebenezzeoebenezzeo Posts: 3Questions: 1Answers: 0

    pls what have i done wrong.... :'( :'( :'(

  • allanallan Posts: 63,205Questions: 1Answers: 10,415 Site admin

    What is the response from the server. The tech note that the error message links to shows how to get that information.

    Allan

  • ebenezzeoebenezzeo Posts: 3Questions: 1Answers: 0

    when i try loading table, i don't know if i've done something wrong, in the server_processing.php i followed the tutorial too, i keep getting error
    DataTables warning: table id=example - Invalid JSON response.

  • kthorngrenkthorngren Posts: 21,167Questions: 26Answers: 4,921

    Did you follow the troubleshooting steps at the link provided in the error?
    https://datatables.net/manual/tech-notes/1

    What did you find?

    Kevin

This discussion has been closed.