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

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

edited February 2011 in General Posts: 16
For some reason, this just started happening. I am getting this error when trying to load in my JSON data with AJAX:
"DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error."

Firebug is giving this error:
Invalid label
{"aaData:" [

Here is the HTML, JS and JSON. I have no idea what happened or why...does anyone here?

Table HTML:
<table id="test_table"> <thead> <tr> <th>One</th> <th>Two</th> <th>Three</th> <th>Four</th> <th>Five</th> <th>Six</th> <th>Seven</th> </tr> </thead> <tbody> </tbody> </table> Javascript:
$('#test_table').dataTable({ "sAjaxSource" : 'dt_ajax.txt' });
JSON Data:
{"aaData": [ [ "<img src=\"images/details_open.png\">", "3S", "38", "09", "300000", "500000", "Test data" ], [ "<img src=\"images/details_open.png\">", "5I", "34", "12", "500000", "1000000", "aaaaa" ], [ "<img src=\"images/details_open.png\">", "Jumbo", "9", "8", "888888", "8888888", "testtt" ] ]}
Thanks in advance! P.S. The data works fine when input directly. Only "sAjaxSource" is getting this error.


  • I have exactly the same problem.
    On my side it is related to the Jquery version change.
    With Jquery 1.4.4 it works fine, but in 1.5 i have the above said error
  • edited February 2011 Posts: 460
    I have JSON parse errors from time to time as well; since my application is polling every few seconds, I just let my application ignore the errors (modified it so that an alert box does not appear). I am also using jQuery 1.5. I did not test extensively in 1.4.x before switching to 1.5 because I started using DataTables close to the same time that 1.5 came out.

    Interestingly, though, I only rarely get the parse error. Code is almost entirely logical, meaning that in a controlled environment, results should either consistently fail or consistently succeed. I'm not sure why it only *periodically* fails to parse properly for me, but I have to admit I have always simply believed that it was the factor OUT of my control (the communication channel between client and server) that was causing the failure, rather than jQuery or DataTables.

    Now that I'm thinking about it more carefully, though, it's worth mentioning that my parse errors almost always happen near initial page load.

    Since JavaScript executes asynchronously, I wonder if in some scenarios there is a timing issue. I am retrieving my JSON with AJAX and server-side processing, and perhaps it's usually taking Juuuuust long enough to get the data; whereas reading it in with a simple HTTP request in the initialize object (dt_ajax.txt), the data arrives before other relevant functions have terminated...? Subsequent refreshes don't need to build the entire DOM from scratch, so the timing of activity for fetching data and rendering the page will be different; something about that difference makes it less likely that I see a parse error once I'm past the initial page load.

    It's just a guess out of the blue, I do wonder if there's a timing issue somewhere.

  • Posts: 460
    Did some quick testing; dropped in 1.4.4, and refreshed my page several times (to force initial page load which is where I usually see the error).

    About one in ten times, I still see the error. Swapped back in 1.5, and same results.. the error didn't seem to appear (for me at least, with my particular environment) any more or less frequently.

    I'm not 100% sure what conclusion to draw. You don't want JSON parse errors EVER, but as I said before I just let my application ignore them when they do appear. But I don't see 1.5 being worse than 1.4.4 in my scenario. They BOTH actually produce a parse error from time to time. It could still be timing... in 1.5, they no doubt refactored certain functions (and I know they overhauled the AJAX module) which might make the error appear more consistently in your particular scenarios.
  • Posts: 22,729
    Another thread discussing this: . Are you using the validation plug-in for jQuery - that appears to cause the issue you are seeing with jQuery 1.5.

  • Yes indeed it was the Validation plug-in. Thank you all for your help!
  • Posts: 97
    Okay, it might be the validation plugin-in, but HOW to deactivate or in general: How to solve this big issue?
  • Posts: 22,729
    Two ways: 1. remove the validation plug-in, 2. upgrade to the very latest validation plug-in code ( ). There are quite a few discussions on the web about this issue with jQuery 1.5 and the jQuery validation plug-in ( ). Basically it appears that the plug-in wraps and overwrites the $.ajax stuff, thus causing the problem since Ajax for an overhaul in jQuery 1.5.

  • Posts: 22
    hello i have the same problem...but iam not able to find out where or how i can disable the validate plug in. i don kno if i hav one. where should i look to find it out. i use jquery.dataTables.min 1.7.6 and jquery.js is 1.2.6. and i am testing on firefox. i print the response in my log4j and the format looks correct.please help.
    my response looks like this:

    { "sEcho": 1, "iTotalRecords": 10, "iTotalDisplayRecords": 10, "aaData": [ ["1","medata","001","1","tom"],["1","medata","001","1","tom"],["1","medata","001","1","tom"],["1","medata","001","1","tom"],["1","medata","001","1","tom"],["1","medata","001","1","tom"],["1","medata","001","1","tom"],["1","medata","001","1","tom"],["1","medata","001","1","tom"],["1","medata","001","1","tom"] ] }

  • Posts: 22,729
    DataTables required jQuery 1.3 or newer due to some of the calls made. If you can upgrade that, I would do so.

  • edited February 2012 Posts: 2
    Hi Allan,

    I've the same issue above. I just doing some test and use your jquery & datatables from your server - jQuery v1.7.1 - 1.9.0

    and below are my json data format and validated already through
    { "sEcho": 0, "iTotalRecords": "34635", "iTotalDisplayRecords": "34635", "aaData": [ [ "MT", "RTWWA", "Kita liat aja nanti asjjdasjjasjfjasfjjajasjfjasjf", "Kita liat aja nanti asjjdasjjasjfjasfjjajasjfjasjf", "Kita liat aja nanti asjjdasjjasjfjasfjjajasjfjasjf" ], [ "wrwr", "dsfdsg", "ewrewr", "ewrewr", "ewrewr" ], [ "wrwer", "ewrew", "ewrew", "ewrew", "ewrew" ] ] }
    but I got Browser Error Message "DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error".

    could you advise me what's the problem of this issue above?

    Thanks in advance.
  • Hi Allan,

    Just ignore my question above. the problem solved, already. Thanks!
  • Hello Allan,

    "DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error".
    could give me the solution ? my json data format from server. but my data comes in body. i could not display the data in table. could you help me?
  • Posts: 22,729
    could give me the solution ?

    Absolutely - use correctly formatted JSON ;-).

    In all seriousness, use to find out why your JSON isn't valid and firebug to get the JSON reply from the server.

  • Hi Allan,
    congratulations for your excellent job.

    I am using
    jquery.dataTables 1.9.0

    I have validated successful my JSON data using
    and the same JSON data works fine on other jQuery / xhr calls.

    Do you see any other reasons about this issue?



    "rows": [
    "row": {
    "ID": "183",
    "Field1": "Barrett Rollins",
    "Field2": "1-759-171-2284",
    "Field3": "[email protected]",
    "Field4": "311 Egestas Rd.",
    "Field5": "Vancouver",
    "Field6": "M3R 2HN",
    "Field7": "Taiwan, Province of China",
    "Field8": "nisi. Mauris nulla. Integer urna. Vivamus molestie dapibus ligula. Aliquam",
    "Field9": "Lorem ipsum dolor sit",
    "Field10": ""
    "row": {
    "ID": "184",
    "Field1": "Lee Terrell",
    "Field2": "1-366-499-3352",
    "Field3": "[email protected]",
    "Field4": "Ap #498-1999 Consectetuer Rd.",
    "Field5": "Brookings",
    "Field6": "30324",
    "Field7": "Papua New Guinea",
    "Field8": "mauris a nunc. In at pede. Cras vulputate velit eu",
    "Field9": "Lorem ipsum dolor",
    "Field10": ""
  • Posts: 22,729
    Are you using both mDataProp and sAjaxDataProp to tell DataTables to look at "rows" and the object parameters in your JSON?

  • Posts: 1
    Hi, I tested my JSON and it's valide but i have this error when i try to use datatbles to show my data: "DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error".

    Any help please????
  • Posts: 22,729
    Please run your table throughout he debugger and link me to the result.

  • Posts: 7
    I consistently get this error when logging out of my website and leaving a page that has an automatically updating DataTable. I suspect it has something to do with leaving the page during a data poll.
  • Posts: 22,729
    Very probably yes - are you using Firefox, I've notice this happening there before. What you could do is set DataTables to exception rather than 'alert' error mode:

    $.fn.dataTableExt.sErrMode = 'throw';
  • a have the samoe error: DataTables warning: JSON data from server could not be parsed
    php returns this json

    "firm_name":"ТКСС ТЕЛЕКОМПЛЕКТ",
    "dlujnost":"Техник механик съобщителни и свързочни съоръжения"
    "firm_name":"ЕНЧЕВ ТРАНС ЕООД",
    "dlujnost":"Пласьор стоки"


    and the JS

    <script type="text/javascript" charset="utf-8">
    $(document).ready(function() { $('#table_rabotni_mesta').dataTable( {"bProcessing": true, "bServerSide": true, "sAjaxSource": "table_server.php", "sServerMethod": "POST",
    "sDom": 'T<"clear">Rlfrtip',
    "bJQueryUI": true, "sPaginationType": "full_numbers",

    //translation plugin
    "oLanguage": { "sUrl": "../lang/"},

    "fnServerParams": function ( aoData ) {
    aoData.push( { "name": "table", "value": "" } );
    aoData.push( { "name": "blah", "value": "blahblah" } );
    aoData.push( { "name": "thing", "value": "thingsvalue" } );
    } } ); } );

    here is the HTML:
    <table cellpadding="0" cellspacing="0" border="0" id="table_rabotni_mesta" class="display"><thead><tr><th></th><th></th><th></th><th></th><th></th></tr></thead><tbody><tr><td colspan="5" class="dataTables_empty">Зареждане на информацията от сървъра</td></tr></tbody><tfoot><tr><th></th><th></th><th></th><th></th><th></th></tr></tfoot></table>


  • Posts: 22,729
    Please link us to the page.
  • Posts: 22,729
    And right enough the server is not returning JSON. It is returning:

    <pre>ORDER BY p.firm_name as firm_name asc</pre><pre></pre><!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"><html><head><title>Error on</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="author" content="еКсперт-2002"><meta name="company" content="eXpert-2002"><meta name="creator" content=""><meta name="designer" content=""><meta name="generator" content="Basic Site System"><meta http-equiv="Cache-Control" content="max-age=0"><meta http-equiv="Cache-Control" content="no-cache"><meta http-equiv="Expires" content="Tue, 01 Jan 1980 1:00:00 GMT"><meta http-equiv="expires" content="-1"><meta http-equiv="Pragma" content="no-cache"><link rel="shortcut icon" href="multimedia/icon/logo.png" ><style type="text/css">body { color: #444444; background-color: #EEEEEE; }h1 { font-size: 2em; }h2 { font-size: 1.2em; }h3 { font-size: 1em; }#page{ background-color: #FFFFFF; width: 60%; margin: 24px auto; padding: 12px; }#header { padding: 6px ; text-align: center; background-color: #475076; color: #FFFFFF; }#content { padding: 4px 0 24px 0; }#footer { color: #666666; background: #f9f9f9; padding: 10px 20px; border-top: 5px #efefef solid; font-size: 0.8em; text-align: center; }#footer a { color: #999999; }</style></head><body><div id="page"><div id="header"><h1>FOUND ERROR !!!</h1></div><div id="content"><h3></h3><h2>Bad query extentions: </h2><h3>SELECT SQL_CALC_FOUND_ROWS p.firm_name as firm_name, DATE_FORMAT(p.date_ot, \'%d.%m.%Y\' )as date_ot, DATE_FORMAT(p.date_do, \'%d.%m.%Y\' )as altnameto, nkpd.kod_2012 as kodnkpd, nkpd.dlujnost as dlujnost FROM personal_staj p LEFT JOIN db_nkpd nkpd ON ORDER BY p.firm_name as firm_name asc LIMIT 0, 10</h3><hr><address>More information about this may be available in the server error log.</address></div><div id="footer"><p>&copy;Copyright 2002-2012 <a href=""></a>; | дизайн и хостинг <a href=""; target="_blank">еКсперт-2002</a></p></div></div></body></html>
  • are you shure .. because i se the json format without those <pre>
    server file is
  • Posts: 22,729
    100% certain. Use Firebug and you'll see what the server is responding with.

  • i got it. bad query in server side because im linking tables automaticly ... now i have [object Object] [object Object] [object Object] [object Object] [object Object] ... probably this one will be interesting for you
  • Posts: 22,729
    Your aaData is an array of arrays of objects. You want to remove the inner array and just have an array of objects.
  • edited October 2012 Posts: 24
    okey .. i removed the inner array
    now the error is "DataTables warning (table id = 'table_rabotni_mesta'): Requested unknown parameter '0' from the data source for row 0".
    am i a total mess :D
  • Posts: 22,729
    You need to tell DataTables which object property should be used for each column:

  • thanks a lot ... :) its WORKING :D
    now im trying to find the topic for "sorting date in DD.MM.YYYY format
    any idea allan ? :)
Sign In or Register to comment.