DataTables warning: table id=participant - Invalid JSON response.
DataTables warning: table id=participant - Invalid JSON response.
HI
no clue why my response from the server shall not be vaild JSON -
I try to implement https://datatables.net/manual/server-side with 10 preloaded rows
every time i try to search or set pagination from 25 to 100 I get
DataTables warning: table id=participant - Invalid JSON response.
But i verified the json answer - it is json to me ! and also to https://jsonlint.com/
Any hints?
Thanks rob
Here is my html
<html lang="en"> <head>
...
</head>
<body>
....
Action | ID | Lastname | Fristname | date of birth | state | ||||
---|---|---|---|---|---|---|---|---|---|
96645546482 | male | DE | Griffin | Daniel | Griffin.Daniel@jlbba.google.com | 03-12-1987 | complete |
....
.... $(document).ready(function() { $('#participant').DataTable({ "processing": true, "serverSide": true, "ajax": "/api/Particicpant_ServerSide.php", "deferLoading": 100, "search": { search: "", }, columnDefs: [ { orderable: false, targets: 0 }, { orderable: false, targets: 8 } ], "order": [[ 1, "desc" ]], "pageLength": 10 } ); }); ...</body>
</html>
Here is the answer (Anonymized data) from the server (limit)
{"draw":0,"recordsTotal":40,"recordsFiltered":40,"data":[["action","116482","male","DE","Griffin","Daniel","Griffin.Daniel@jlbba.google.com","03-12-1987","status","action_status"],["action","116481","male","DE","Cooper","John","Cooper.John@ruzot.google.com","23-02-1993","status","action_status"],["action","116480","female","DE","Washington","Maria","Washington.Maria@isrew.mail.com","12-04-1989","status","action_status"],["action","116479","female","DE","Gonzalez","Joseph","Gonzalez.Joseph@nmtkr.yahoo.com","21-01-1991","status","action_status"],["action","116478","male","DE","Gray","Joshua","Gray.Joshua@gyyxr.live.com","13-08-1993","status","action_status"],["action","116477","female","DE","Reed","Edward","Reed.Edward@vxbpu.google.com","19-01-1980","status","action_status"],["action","116476","male","DE","Cox","Maria","Cox.Maria@cceoh.live.com","23-12-1977","status","action_status"],["action","116475","male","DE","Nelson","Donna","Nelson.Donna@jsmeo.google.com","08-11-1975","status","action_status"],["action","116474","male","DE","Rivera","Ruth","Rivera.Ruth@silgz.google.com","19-11-1985","status","action_status"],["action","116473","male","DE","Smith","Barbara","Smith.Barbara@gqkfv.yahoo.com","22-08-1979","status","action_status"],["action","116472","male","DE","Williams","Henry","Williams.Henry@emuol.live.com","20-06-1988","status","action_status"], ...
This question has an accepted answers - jump to answer
Answers
Yep, I agree, that JSON looks good. It doesn't look like a valid response though, as the
draw
should match what was sent in the request. The first request would be1
, so0
looks suspiscious.If that doesn't resolve the problem, could you link to your page so we can take a look, please.
Colin
Hi Colin
thanks - since it is a test system you can have acess
https://comsii.bpmspace.net/index.php?target=participant_grid
user: Colin
paaswd: Colin9843756983
https://comsii.bpmspace.net/api/Particicpant_ServerSide.php
Thanks rob
Looking at the browser's network inspector I see the following response:
There are extra lines at the top causing the error. Looks like the response you show with
draw: 0
is from this link directly:https://comsii.bpmspace.net/api/Particicpant_ServerSide.php
So its not seeing the parameters sent by Datatables and not generating the errors above. For troubleshooting its better to use the browser's network inspector to see the actual response.
Not sure why your server script is generating those errors.
Kevin
$sql_details is set in an config file
the example also starts with {"draw": ....
With server die processing enabled the
draw
and other parameters you see are expected. Please see the server side processing protocol docs for more details.The problem is with lines 1 - 6 in the output I posted above. You will need to troubleshoot your server script to find out why its returning those lines and remove them.
Kevin
OK - got it! - working! - Thank you rob