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

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

darstar007darstar007 Posts: 9Questions: 0Answers: 0
edited August 2012 in General
Hi,

I had a nice app using datatables and mysql running on my windows 7 pc. I ported everything to RHEL4 and everything should be working (did not change anything as far as the backend database or php scripts and the directory structure); however, now I'm getting the following error when I attempt to access the main page which uses Datatables:

DataTables warning (table id = 'example'): DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error.

I did not change anything that should cause any differences. The data is identical as well.

Any ideas on how I can debug this?

Thank you

Replies

  • darstar007darstar007 Posts: 9Questions: 0Answers: 0
    BTW, when I run the php from the command line, data IS returned. So the connection to database is not the issue.
  • darstar007darstar007 Posts: 9Questions: 0Answers: 0
    edited August 2012
    removed
  • darstar007darstar007 Posts: 9Questions: 0Answers: 0
    I have further found that the output of server_processing.php is identical on the working and non-working system. A diff on the output results in nothing.
  • darstar007darstar007 Posts: 9Questions: 0Answers: 0
    Additionally I have entered the json output in http://jsonlint.com/ and found the result to be valid!!!

    This error is causing major headaches. Any help out there???
  • darstar007darstar007 Posts: 9Questions: 0Answers: 0
    Format of JSON output:

    {
    "sEcho": 0,
    "iTotalRecords": "1121",
    "iTotalDisplayRecords": "1121",
    "aaData": [
    [
    "Naci",
    "uint64",
    "new_agency_contract_id",
    "ESF",
    "Custom new_agency_contract_id field.",
    "1"
    ],
    [
    "Nced",
    "uint64",
    "new_commission_end_date",
    "ESF",
    "Custom new_commission_end_date field.",
    "2"
    ]
    ................................
    ]
    }
  • darstar007darstar007 Posts: 9Questions: 0Answers: 0
    edited August 2012
    I modified the code from

    [code]
    "bProcessing": true,
    "bServerSide": true,
    "sAjaxSource": "scripts/attr.php"
    [/code]

    to

    [code]
    "bProcessing": true,
    "sAjaxSource": "scripts/json.txt"
    [/code]

    where json.txt was generated by running: php -f scripts/attr.php > scripts/json.txt

    and it now works!!! The permissions on all files and directories are 777, so that should not be an issue.

    This does not solve my problem, because I want the data to be live.

    Does anyone have an idea? Is anyone even out there????
  • darstar007darstar007 Posts: 9Questions: 0Answers: 0
    I have a kludgy workaround where I generate the json.txt file everytime the page loads, but I really want to get the ServerSide code working.
  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin
    > "sEcho": 0,

    That doesn't look good - sEcho should never be 0. See: http://datatables.net/usage/server-side

    > Any ideas on how I can debug this?

    http://datatables.net/forums/discussion/9719/how-to-ask-for-help
    1. Give us a link
    2. Use the debugger and give us the code :-)

    Allan
  • darstar007darstar007 Posts: 9Questions: 0Answers: 0
    Problem solved. The issue was related to the apache config.
  • anoint216371anoint216371 Posts: 1Questions: 0Answers: 0
    edited September 2012
    i have same problem.
    please can you tell me how to configuration to apache config?
    thanks
  • FicosFicos Posts: 88Questions: 22Answers: 0
    I have the same problem as well. So PLEASE tell me how to configure apache config.
    thank you
  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin
    @anoint216371 and @Ficos

    See my previous comment:

    [code]
    http://datatables.net/forums/discussion/9719/how-to-ask-for-help
    1. Give us a link
    2. Use the debugger and give us the code :-)
    [/code]

    Allan
This discussion has been closed.