JSON Error (jsonlint validates)

JSON Error (jsonlint validates)

cirphrcirphr Posts: 4Questions: 0Answers: 0
edited January 2012 in General
Any help would be great.

I'm using the php example for server side processing and running the PHP page i'm using for server side processing shows me everything is ok and returning json output as expected, but I get the following error from data tables:

DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error.

Here's the output which validates on JSONLint, I thought it was the date at first but removing the '/' doesn't fix it either.

{"sEcho":0,"iTotalRecords":"1","iTotalDisplayRecords":"1","aaData":[["1","Dummy","Dummy","Dummy","Dummy","09\/01\/2012","Dummy","10\/01\/2012","Dummy","Dummy"]]}

I even tried switching the db record to all dummy's to get:

{"sEcho":0,"iTotalRecords":"1","iTotalDisplayRecords":"1","aaData":[["1","Dummy","Dummy","Dummy","Dummy","Dummy","Dummy","Dummy","Dummy","Dummy"]]}

Any idea why it's complaining about JSON error? It just doesn't want to work for some reason....

Table innitialization:
[code]
$('#table').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "./create.php",
"bSort": true,
"bJQueryUI": true,
"bFilter": true,
"sSearch": "Search all columns:",
"bSearchable": true,
"bStateSave": true,
"sPaginationType": "full_numbers",
"aaSorting": [[ 5, "desc" ]],
"aoColumns": [
{ "sType": 'string-case', "sWidth": "0%"},
{ "sType": 'string-case', "sWidth": "0%"},
{ "sType": 'string-case', "sWidth": "15%"},
{ "sType": 'string-case', "sWidth": "5%" },
{ "sType": 'string-case', "sWidth": "5%" },
{ "sType": 'date-case', "sWidth": "10%"},
{ "sType": 'date-case', "sWidth": "10%"},
{ "sType": 'date-case', "sWidth": "10%"},
{ "sType": 'string-case', "sWidth": "5%" },
{ "sType": 'string-case', "sWidth": "45%"},
],
"aoColumnDefs": [
{ "bVisible": false, "aTargets": [ 0 ] }, //Row ID column
{ "bVisible": false, "aTargets": [ 1 ] }, //GGID column
],
"fnDrawCallback": function () {
$('#display tbody td').editable( './edit.php', {
"callback": function( sValue, y ) {
/* Redraw the table from the new data on the server */
oTable.fnDraw();
},
"submitdata": function ( value, settings ) {
return {
"row_id": this.parentNode.getAttribute('id'),
"col_id": oTable.fnGetPosition( this )[2],
};
},
"height": "14px"
});
}
});
[/code]

Replies

  • cirphrcirphr Posts: 4Questions: 0Answers: 0
    edited January 2012
    Also when I use JSON in the example I still get the same validation error....Even when I use the example that comes with Data Tables for server side processing (and setup the DB accordingly) I get a JSON error. It just won't work no matter what, could this a problem with jquery or setup?

    Nothing works with the JSON i'm generating with PHP.
  • allanallan Posts: 63,538Questions: 1Answers: 10,476 Site admin
    I would guess that something is injecting some plain text in tot he return - a PHP warning or something. Can you link me to your example please and I'll be able to say what the problem is then.

    Thanks,
    Allan
This discussion has been closed.