DataTables warning: JSON data from server could not be parsed. - Page 2

DataTables warning: JSON data from server could not be parsed.

2

Replies

  • allanallan Posts: 61,438Questions: 1Answers: 10,049 Site admin
    http://datatables.net/plug-ins/sorting#date_eu
  • DUCKFACEDUCKFACE Posts: 24Questions: 0Answers: 0
    allan thanks
    right now im reading this http://datatables.net/forums/discussion/8551/tabletools-not-working/p1 because i have the same problem. any ideas ?
  • allanallan Posts: 61,438Questions: 1Answers: 10,049 Site admin
    Yes - set the SWF path. If you are a 404 error, you need to change to path to fix the error.
  • DUCKFACEDUCKFACE Posts: 24Questions: 0Answers: 0
    i dont have 404 error
  • allanallan Posts: 61,438Questions: 1Answers: 10,049 Site admin
    In that case we'd need a link to see what the problem is.
  • DUCKFACEDUCKFACE Posts: 24Questions: 0Answers: 0
    the same as the one posted before table_view.php
  • allanallan Posts: 61,438Questions: 1Answers: 10,049 Site admin
    5 404 errors:

    [quote]
    jquery-ColReorder.js Failed to load resource: the server responded with a status of 404 (Not Found)
    jquery-KeyTable.js Failed to load resource: the server responded with a status of 404 (Not Found)
    jquery-TableTools.js Failed to load resource: the server responded with a status of 404 (Not Found)
    jquery-ColVis.js Failed to load resource: the server responded with a status of 404 (Not Found)
    jquery-ZeroClipboard.js Failed to load resource: the server responded with a status of 404 (Not Found)
    [/quote]
  • DUCKFACEDUCKFACE Posts: 24Questions: 0Answers: 0
    the files are there .. otherwise i will not be able to use the other functions
  • DUCKFACEDUCKFACE Posts: 24Questions: 0Answers: 0
    GET jquery.js 304 Not Modified
    GET jquery-ui.js 304 Not Modified
    GET jquery-tools.js 304 Not Modified
    GET jquery-dataTables.js 304 Not Modified
    GET jquery-ColReorder.js 304 Not Modified
    GET jquery-ColVis.js 304 Not Modified
    GET jquery-KeyTable.js 304 Not Modified
    GET jquery-TableTools.js 304 Not Modified
    GET jquery-ZeroClipboard.js 304 Not Modified
    if there is na 404 error for all those .js i wont be able to use them ... but
    i can use the rest of the "extras"
    only the keytable ... not working
  • allenbrownallenbrown Posts: 3Questions: 0Answers: 0
    Hello

    Firstly, can I add my compliments to the mass of praise you've deservedly had for this plug-in. I have used it in many applications, especially in CRUD-style admin applications, and it's excellent.

    But now I have this same error: "DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error.", but I only have in IE8. I developed and tested using Chrome and Firefox and have only stared checking IE8 now everything works ok. So my app works fine in Chrome, Safari and Firefox but not in IE8. The JSON goes through lint without any error.

    How do I debug this, given that I can't reproduce the error in Firefox?
  • allanallan Posts: 61,438Questions: 1Answers: 10,049 Site admin
    If it is IE only then very likely you have a trailing comma.

    If you could give us a link, that would be helpful.

    Allan
  • allenbrownallenbrown Posts: 3Questions: 0Answers: 0
    edited November 2012
    Thanks Allan. There's security on this app at the moment but I have made a copy so you can look at it. I have sent you the URL by PM rather than put it here.

    I thought I'd solved it last night when I noticed that IE9 wasn't accepting the JSON as JSON and was putting up a 'Save As' box instead. I solved this by changing the headers from:

    header('Content-type: application/json');

    to:

    header('Content-Type: text/plain');
    header('X-Content-Type-Options: nosniff');

    That kept IE8 happy but didn't stop it working in Firefox or Chrome.

    However, still the same error.
  • allenbrownallenbrown Posts: 3Questions: 0Answers: 0
    By the way, I did look for trailing commas but I'm pretty confident I don't have any. JSLint reports extra trailing commas.
  • megatypemegatype Posts: 1Questions: 0Answers: 0
    Help?! Having the same problem on my Cart66 Professional. "DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error."

    I don't know what I'm doing, so basic level instructions would be really helpful. I've submitted a support ticket but there seems to be no help. The problem is prevent cart66 from working. When we click on the button to add to cart it says "readyState:4 Status: 200" Thank you!

    http://the-human-solution.org/take-action/membership/
  • allanallan Posts: 61,438Questions: 1Answers: 10,049 Site admin
    Where have you submitted a ticket? I don't have a record of anything.

    I also don't actually see how to reproduce the error. I click the add to cart button and get he readyState alert, but nothing about JSON formatting error.

    Needless to say, the JSON formatter error is exactly what it says on the tin - invalid JSON.

    Allan
  • efirvidaefirvida Posts: 3Questions: 0Answers: 0
    i am using firebug (first time) to identify the json error, but i can't find the json tab. Could anyone help me, please?
    Jane
  • dimitryousdimitryous Posts: 4Questions: 0Answers: 0
    edited August 2013
    Just for your information: Few hours ago I just upgrade to php 5.5 from php 5.4.6: DataTables not working anymore... Got the same error message "DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error.".
    This message out only for the ServerSide example (I mean mySQL queries with "server_processing.php")...
    So, I do believe there is a bug somewhere as "the stuff was working before the upgrade".
    MacOS 10.8.3, Apache/2.2.22 (Unix) PHP/5.5.0 mod_jk/1.2.37 DAV/2 mod_ssl/2.2.22 OpenSSL/0.9.8x mod_perl/2.0.5 Perl/v5.12.4 - Server type: MySQL
    Server version: 5.5.28 - MySQL Community Server (GPL)

    edit: The tables used are installed from the "data.sql" file coming with the package...
    edit(2): same problem with FireFox on the same machine...
  • allanallan Posts: 61,438Questions: 1Answers: 10,049 Site admin
    What is the error in the Ajax return from the server? It isn't valid JSON, so it is likely to be an error message stating what the problem is.

    Allan
  • dimitryousdimitryous Posts: 4Questions: 0Answers: 0
    ... and the error message is: "TypeError: 'undefined' is not an object (evaluating 'oColumn.asSorting')" at line 6705 (jquery.dataTables.js:6705)
  • allanallan Posts: 61,438Questions: 1Answers: 10,049 Site admin
    That's the Javascript error. What is the error coming back from the server in the Ajax request. Please use the DataTables debugger or give us a link and we might be able to help more.

    Allan
  • dimitryousdimitryous Posts: 4Questions: 0Answers: 0
    Sorry Allan: I have to write a few lines of php code to achieve your request. As for a link, I have only one machine running php 5.5. It may come out from this story I took a very bad decision to upgrade from php 5.4.6... Thanks for your help and the good work. p.s. I just completed the necessary #bash routines to easily switch back and forth between php versions... (not so easy in fact).
  • dimitryousdimitryous Posts: 4Questions: 0Answers: 0
    Allan: after a complete rewrite of the script server_processing.php I got the right results. The error was mainly due to a mysql_pconnect command which no longer exist in php version 5.5.0 and above, to be replaced by "mysqli_connect" (procedural style) or "mysqli::select_db" (object oriented style).
    So, as far as I'm concerned, the discussion is closed.
    Thank you again for the good work.
    d.
    p.s. I use the code to display huge "geoip" related data stored in MySQL databases...
  • allanallan Posts: 61,438Questions: 1Answers: 10,049 Site admin
    Ah okay. I think I need to get around to writing the server_processing.php change that I've been thinking needs to be done! Thanks for the feedback and good to hear it is now working for you.

    Regards,
    Allan
  • robertyroberty Posts: 5Questions: 0Answers: 0
    edited August 2013
    Hi Allan, I am getting the same error message "DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error." as mentioned above. I've taken the $output and run it through JSONLint and it checks out as valid JSON. So now I don't know what to do to solve the problem. I've also looked at it through the DataTables debugger, but nothing jumped out at me as a clue. I am using the example script for Server-side processing | PHP with MSSQL ODBC driver. I am connecting to a SQL ServerExpress 2008 database. Using jQuery version 1.7.2. The script should work, yet I get this error. What should I look for to correct the problem?
  • allanallan Posts: 61,438Questions: 1Answers: 10,049 Site admin
    Please link us to the debug trace or to the page.

    Allan
  • robertyroberty Posts: 5Questions: 0Answers: 0
    Hi Allan,
    I've continued to try to figure out why the "...could not be parsed" error appears even though the aaData is validated. I've cleaned up some of the datatable definitions. But nothing helps. Have you seen anything that doesn't look right? Any suggestions yet?

    Here is an updated debug trace page: http://debug.datatables.net/oduzaq
    Here is the web page: http://173.248.176.202/sqlrawdatatables.php
    Here is the call to the database: http://173.248.176.202/includes/content/datatables_sqldata-odbc.php

    Any light that you can shed on this is appreciated.
    Robert
  • robertyroberty Posts: 5Questions: 0Answers: 0
    Hi Allan,
    Here is the link to the debug trace: http://debug.datatables.net/alotoj

    Thanks, Robert
  • robertyroberty Posts: 5Questions: 0Answers: 0
    Here is the debug trace: http://debug.datatables.net/alotoj

    Thanks, Robert
  • allanallan Posts: 61,438Questions: 1Answers: 10,049 Site admin
    Hi Robert,

    This is what is being returned from the server:

    [code]
    < title > Datatables - SQLData < /title>

    {"sEcho":1,"iTotalRecords":20,"iTotalDisplayRecords":20,"aaData":[[999,"Amelti Testing","Roger","Kronborg","Norway"],[1001,"Oppland Metall",null,null,"Norway"],[1002,"Transportpartner",null,null,null],[1003,"Gran Taralrud",null,null,null],[1005,"Toten Transport",null,null,"Norway"],[1006,"Eesti Energia","Urmas","Voit, Jr","Estonia"],[1007,"Friendly Food Qatar",null,null,"Qatar"],[1008,"Odeh Naber & Sons Transport Co",null,null,"Jordan"],[1009,"Modern Energy","John","Stevens","Canada"],[1010,"TS T\u00f8nsberg",null,null,"Norway"]]}
    [/code]

    The title tag at the top is making the return invalid JSON. I'm not sure what will be adding that to the output, but there is something in your script which is doing so. Removing that will resolve the invalid JSON warning since it will be valid JSON thereafter :-)

    Regards,
    Allan
  • robertyroberty Posts: 5Questions: 0Answers: 0
    I will see if I can figure out what is causing it. Thanks for your help!
    Robert
This discussion has been closed.