Server-side processing, Invalid JSON response

Server-side processing, Invalid JSON response

pernillapernilla Posts: 2Questions: 1Answers: 0

Hello,

I'm currently trying to get the server-side to work for my setup, but receiving no reponse.

I'm using the server-side example provided here: https://datatables.net/examples/server_side/simple.html
The database settings have been changed to match my setup, but otherwise the code is mostly untouched.

DataTables Debugger link: http://debug.datatables.net/ovujig

Any help would be appreciated, thanks!

This question has accepted answers - jump to:

Answers

  • bindridbindrid Posts: 730Questions: 0Answers: 119
    Answer ✓

    here are some things you can do to figure out what the problem is

    This is basically what your stuff looks like from looking at the debug file.

            $("table").DataTable({
                "processing": true,
                "serverSide": true,
                "ajax": "files/server_processing.php",
                "columns": [{
                    "data": "id",
                    "mData": "id"
                }, {
                    "data": "name",
                    "mData": "name"
                }, {
                    "data": "date",
                    "mData": "date"
                }],
    
            });
    

    This code adds to it a bit to help you debug where the problem is.
    Run is with your console open to confirm what is being sent where.
    Also, you can run ajax by itself and see if you can get data that way.

    ```

        $("table").DataTable({
            "processing": true,
            "serverSide": true,
            "ajax": {
                url:"files/server_processing.php",
                "data":function(outData){
                    // what is being sent to the server
                    console.log(outData);
                    return outData;
                },
                dataFilter:function(inData){
                    // what is being sent back from the server (if no error)
                    console.log(inData);
                    return inData;
                },
                error:function(err, status){
                    // what error is seen(it could be either server side or client side.
                    console.log(err);
                },
            },
            "columns": [{
                "data": "id",
    
            }, {
                "data": "name",
    
            }, {
                "data": "date",
    
            }],
    
        });
       ```
    
  • allanallan Posts: 63,889Questions: 1Answers: 10,530 Site admin
    Answer ✓

    The debugger trace shows that the files/server_processing.php script is not responding with anything - i.e. zero length data.

    I'd suggest the first stop should be to check your server's error logs to see if there is anything reported there.

    Allan

  • pernillapernilla Posts: 2Questions: 1Answers: 0

    Looks like PDO was not enabled. Thanks for the help!

This discussion has been closed.