JSON response validated ok, but receive Invalid JSON response.

JSON response validated ok, but receive Invalid JSON response.

aer5aer5 Posts: 3Questions: 1Answers: 0

**Debugger code (debug.datatables.net)
: https://debug.datatables.net/anutib
Error messages shown: DataTables warning: table id=example - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1
Description of problem:

JSON response validated online ok, but receive Invalid JSON response message, this is my html

<html lang="en" xmlns="http://www.w3.org/1999/html">
<meta charset="UTF-8">

<link href="../../css/bootstrap-5.0.2-dist/css/bootstrap.css" rel="stylesheet">

<link rel="stylesheet" type="text/css" href="../ext_assets/DataTables/datatables.css"/>


arbeitgeber position
arbeitgeber position
$('#example').dataTable( { "processing": true, "serverSide": true, "ajax": { "url": "server_processing.php", "dataType": "jsonp" } } );


and this the server-side script:

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);

// DB table to use
$table = 'minify';

// Table's primary key
$primaryKey = 'id';

$columns = array(
array( 'db' => 'arbeitgeber', 'dt' => 0 ),
array( 'db' => 'position', 'dt' => 1 )

// SQL server connection information
$sql_details = array(
'user' => 'aer_talea',
'pass' => 'z&5T94jp',
'db' => 'web11573_talea-advisory',
'host' => 'localhost:3306'

require( 'ssp.class.php' );

echo json_encode(
SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns )

thanks in advance

This question has an accepted answers - jump to answer


  • kthorngrenkthorngren Posts: 20,475Questions: 26Answers: 4,804
    Answer ✓

    In your browser use the network inspector to get the JSON response. In Chorme use the Response tab and copy the whole response. Paste it into https://jsonlint.com/ and you will find that it is not valid. The response as this at the end which makes it not valid:


    Take a look at this JSONP example. The response looks like this:

        "draw": 1,
        "recordsTotal": 57,
        "recordsFiltered": 57,
        "data": [
            ["Airi", "Satou", "Accountant", "Tokyo", "28th Nov 08", "$162,700"],

    I don't use PHP but if you look at the bottom of the script in teh Server-side Script tab you will see some additional code to handle the JSONP request. Looks like you might need to add that to your script.


  • aer5aer5 Posts: 3Questions: 1Answers: 0

    Hi Kevin, thanks, i included the two js-files:
    and the json is valid, but still not working...

  • aer5aer5 Posts: 3Questions: 1Answers: 0

    Solved this make it work:
    $('#example').dataTable( { "processing": true, "serverSide": true, "ajax": { "url": "server_processing.php", "dataType": json" } } );

    dataType json instead of jsonp

    Regards Armin

Sign In or Register to comment.