Invalid JSON Response from datatable server side

Viewed 1875

I'm using the jQuery Datatable plugin and started doing a server-side activation due to the large volume of data being registered.

I did everything with the same basics, just as it is in the documentation, but when loading it it informs an alert:

Warning DataTables: table id = example - Invalid JSON response. For more information about this error, see http://datatables.net/tn/1.

Following as instructions, I debugged, and in the last step, where it is to show the JSON with the data, it appears: This request has no response data available.

Why is this error still happening? Detail: If I change JUST the fields, on the server_processing.php page in the default it works perfectly, is the database?

The page with the simple.html table:

<script type="text/javascript" language="javascript" class="init">

$(document).ready(function() {
    $('#example').DataTable( {
        "processing": true,
        "serverSide": true,
        "ajax": "scripts/server_processing.php"
    } );
    (function() {
    var url = '//debug.datatables.net/bookmarklet/DT_Debug.js';
    if (typeof DT_Debug != 'undefined') {
        if (DT_Debug.instance !== null) {
            DT_Debug.close();
        } else {
            new DT_Debug();
        }
    } else {
        var n = document.createElement('script');
        n.setAttribute('language', 'JavaScript');
        n.setAttribute('src', url + '?rand=' + new Date().getTime());
        document.body.appendChild(n);
    }
})();
} );

    </script>
</head>
<body class="dt-example">
    <div class="container">
        <section>
            <div class="demo-html"></div>
            <table id="example" class="display" cellspacing="0" width="100%">
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>Razão Social</th>
                        <th>CNPJ</th>
                        <th>CEP</th>
                        <th>Rua</th>
                        <th>Cidade</th>
                    </tr>
                </thead>
            </table>
        </section>
    </div>
    <br>
</body>

And server_processing.php:

<?php
$table = 'tbl_company';
$primaryKey = 'id_Company';

$columns = array(
    array( 'db' => 'id_Company', 'dt' => 0 ),
    array( 'db' => 'razaoSocial',  'dt' => 1 ),
    array( 'db' => 'cnpj',   'dt' => 2 ),
    array( 'db' => 'cep',     'dt' => 3 ),
    array( 'db' => 'rua',   'dt' => 4 ),
    array( 'db' => 'cidade',     'dt' => 5 )
);


$sql_details = array(
    'user' => '***', //User
    'pass' => '***', //Pass
    'db'   => '***', //DB
    'host' => 'localhost'
);

require_once( 'ssp.class.php' );
echo json_encode(
    SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns )
);

I even did another debug, the datatable debugger, here is the response. Nothing.

0 Answers
Related