Ajax error while server-side-proc

Ajax error while server-side-proc

RobinsonHuRobinsonHu Posts: 8Questions: 3Answers: 1

Hi, after I got a hint to switch to server-side-proc (because of ~20.000 entries and slow page loading) I just tried it.

On my webserver are 2 files like in the example on this website: server_processing.php and test.htm
Here the source:

<!DOCTYPE html>
<html>
  <head>
    <title>Person Information</title>
    <meta charset="UTF-8"> 
    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.20/css/jquery.dataTables.min.css"/>
    <script type="text/javascript" language="javascript" src="https://code.jquery.com/jquery-3.3.1.js"></script>
    <script type="text/javascript" language="javascript" src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js"></script>
<script>
$(document).ready(function() {
    $('#example').DataTable( {
        "processing": true,
        "serverSide": true,
        "ajax": "/server_processing.php"
    } );
} );
</script>
  </head>



<table id="example" class="display" style="width:100%">
<thead><tr>
    <th title="Field #1">playerid</th>
    <th title="Field #2">playername</th>
    <th title="Field #3">age</th>
    <th title="Field #4">nation</th>
    <th title="Field #5">teamid</th>
    <th title="Field #6">team</th>
    <th title="Field #7">overall</th>
    <th title="Field #8">potential</th>
</tr></thead>
</table>
<?php
 $table = 'example';
$primaryKey = 'playerid';
$columns = array(
    array( 'db' => 'playerid', 'dt' => 0 ),
    array( 'db' => 'playername',  'dt' => 1 ),
    array( 'db' => 'age',   'dt' => 2 ),
    array( 'db' => 'nation',     'dt' => 3 ),
    array( 'db' => 'teamid',     'dt' => 4 ),
    array( 'db' => 'team',     'dt' => 5 ),
    array( 'db' => 'overall',     'dt' => 6 ),
    array( 'db' => 'potential',     'dt' => 7 )
);
$sql_details = array(
    'user' => 'myusername',
    'pass' => 'mypassword',
    'db'   => 'mydatabasename',
    'host' => 'localhost'
);
require( 'ssp.class.php' );
echo json_encode(
    SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns )
);

After browsing the test.htm I get the following message: DataTables warning: table id=example - Ajax error. For more information about this error, please see http://datatables.net/tn/7

I just tried to use the debugger like its shown in datatables.net/tn/7 but not sure how to deal with it..

The XHR has status 500 and the content of it is:

http://MYWEBSERVER.COM/server_processing.php?draw=1&columns%5B0%5D%5Bdata%5D=0&columns%5B0%5D%5Bname%5D=&columns%5B0%5D%5Bsearchable%5D=true&columns%5B0%5D%5Borderable%5D=true&columns%5B0%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B0%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B1%5D%5Bdata%5D=1&columns%5B1%5D%5Bname%5D=&columns%5B1%5D%5Bsearchable%5D=true&columns%5B1%5D%5Borderable%5D=true&columns%5B1%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B1%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B2%5D%5Bdata%5D=2&columns%5B2%5D%5Bname%5D=&columns%5B2%5D%5Bsearchable%5D=true&columns%5B2%5D%5Borderable%5D=true&columns%5B2%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B2%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B3%5D%5Bdata%5D=3&columns%5B3%5D%5Bname%5D=&columns%5B3%5D%5Bsearchable%5D=true&columns%5B3%5D%5Borderable%5D=true&columns%5B3%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B3%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B4%5D%5Bdata%5D=4&columns%5B4%5D%5Bname%5D=&columns%5B4%5D%5Bsearchable%5D=true&columns%5B4%5D%5Borderable%5D=true&columns%5B4%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B4%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B5%5D%5Bdata%5D=5&columns%5B5%5D%5Bname%5D=&columns%5B5%5D%5Bsearchable%5D=true&columns%5B5%5D%5Borderable%5D=true&columns%5B5%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B5%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B6%5D%5Bdata%5D=6&columns%5B6%5D%5Bname%5D=&columns%5B6%5D%5Bsearchable%5D=true&columns%5B6%5D%5Borderable%5D=true&columns%5B6%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B6%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B7%5D%5Bdata%5D=7&columns%5B7%5D%5Bname%5D=&columns%5B7%5D%5Bsearchable%5D=true&columns%5B7%5D%5Borderable%5D=true&columns%5B7%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B7%5D%5Bsearch%5D%5Bregex%5D=false&order%5B0%5D%5Bcolumn%5D=0&order%5B0%5D%5Bdir%5D=asc&start=0&length=10&search%5Bvalue%5D=&search%5Bregex%5D=false&_=1580992485756

Did I miss something? Thanks.

Answers

  • RobinsonHuRobinsonHu Posts: 8Questions: 3Answers: 1

    Ok that was my fault and I should check the logs before opening a question... ssp was missing (or better I had a typo in the filename)

    Now I get this message: DataTables warning: table id=example - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1

  • RobinsonHuRobinsonHu Posts: 8Questions: 3Answers: 1

    I solved it! For anyone who has the same problem -> it was f**king encoding :disappointed: Just set it (in my case utf-8) up in the ssp-config/file.

Sign In or Register to comment.