Server side processing JSON formatting error

Server side processing JSON formatting error

prakash1981prakash1981 Posts: 8Questions: 0Answers: 0
edited May 2012 in DataTables 1.8
Hello Sir,

I have used JQuery data table for one of my application.

If the data is less it is not having any issues and works as expected.

When the record count increased to thousands, the processing was slow hence I moved the data fetch part to server side processing using linq. We have used the json serialization using the JavaScriptSerializer class in the handler.

I have handled the null value filter for recordset in the LINQ itself.

There was no issue with the speed of data retrieval, but some times we are getting error while the data is loading.

We have also implemented footer search for all the individual columns.

We have used Visual STudio 2010 IDE.

Please find the code snippet from javascript file
[code]
oTable = $('#tblUser').dataTable(

{ "oLanguage": { "sSearch": "Filter:" },
"sPaginationType": "full_numbers",
'bProcessing': true,
'bServerSide': true,
"bFilter": true,
"aoColumns": [
null,
null,
null,
null,
null,
null,
null,
{ "bSortable": false },
{ "bSortable": false }
],
'sAjaxSource': '../Masters/Handler/TestForm.ashx',
"fnServerData": function (sSource, aoData, fnCallback) {
//debugger;
$.ajax({
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"cache": true,
"timeout": 40000,
"success": fnCallback,
"error": handleAjaxError
});
}
});

[/code]
The error is as follows -
DataTables warning: JSON data from server could not be parsed. This is caused by JSON formatting error.

This is causing big block in delivering this application.

Kindly guide me on how can I solve this error?


Regards,
Prakash

Replies

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    What does the JSON reply from the server look like? I'll be able to see it in Firebug / Inspector.

    Allan
  • prakash1981prakash1981 Posts: 8Questions: 0Answers: 0
    some time i got error on sEchois undefined on jquery.dataTables.min.js

    once i got DataTables warning: JSON data from server could not be parsed. This is caused by JSON formatting error my entire application internet information service got blocked.

    so host application connection will be service unavailable error throwing to user

    [code]
    {"iTotalRecords":23,"iTotalDisplayRecords":23,"aaData":[["111","qwerty","zzzzzz","hey..","qwerty@mn.com","sswaminathan","2012-05-03 23:15:05","\u003ca href=\u0027\u0027 alt=Details style=color:#325C91; onclick=\u0027return Popup(111)\u0027\u003eDetails\u003c/a\u003e","\u003ca\u003e \u003cimg id=111 src=../images/edit.png style=visibility:visible alt=Edit /\u003e \u003c/a\u003e \u003ca\u003e \u003cimg id=111 src=../images/delete.gif style=visibility:visible alt=Delete /\u003e\u003c/a\u003e"],["123456","rrrrrr","qwerty","hhhh","karpagam@cognizant.com","sswaminathan","2012-05-03 13:01:44","\u003ca href=\u0027\u0027 alt=Details style=color:#325C91; onclick=\u0027return Popup(123456)\u0027\u003eDetails\u003c/a\u003e","\u003ca\u003e \u003cimg id=123456 src=../images/edit.png style=visibility:visible alt=Edit /\u003e \u003c/a\u003e \u003ca\u003e \u003cimg id=123456 src=../images/delete.gif style=visibility:visible alt=Delete /\u003e\u003c/a\u003e"],["223469","T S, Ram Prabhu","Administrator","","","sswaminathan","2012-05-30 22:07:51","\u003ca href=\u0027\u0027 alt=Details style=color:#325C91; onclick=\u0027return Popup(223469)\u0027\u003eDetails\u003c/a\u003e","\u003ca\u003e \u003cimg id=223469 src=../images/edit.png style=visibility:visible alt=Edit /\u003e \u003c/a\u003e \u003ca\u003e \u003cimg id=223469 src=../images/delete.gif style=visibility:visible alt=Delete /\u003e\u003c/a\u003e"],["251141","Thanu","Test Admin","Manager","thanoj.kamireddy@cognizant.com","sswaminathan","2012-05-04 20:06:08","\u003ca href=\u0027\u0027 alt=Details style=color:#325C91; onclick=\u0027return Popup(251141)\u0027\u003eDetails\u003c/a\u003e","\u003ca\u003e \u003cimg id=251141 src=../images/edit.png style=visibility:visible alt=Edit /\u003e \u003c/a\u003e \u003ca\u003e \u003cimg id=251141 src=../images/delete.gif style=visibility:visible alt=Delete /\u003e\u003c/a\u003e"],["251787","Prabu Das","Administrator","","","251787","2012-05-25 22:23:01","\u003ca href=\u0027\u0027 alt=Details style=color:#325C91; onclick=\u0027return Popup(251787)\u0027\u003eDetails\u003c/a\u003e","\u003ca\u003e \u003cimg id=251787 src=../images/edit.png style=visibility:visible alt=Edit /\u003e \u003c/a\u003e \u003ca\u003e \u003cimg id=251787 src=../images/delete.gif style=visibility:visible alt=Delete /\u003e\u003c/a\u003e"],["269507","Prakash K","Administrator","","","sswaminathan","2012-05-22 13:12:57","\u003ca href=\u0027\u0027 alt=Details style=color:#325C91; onclick=\u0027return Popup(269507)\u0027\u003eDetails\u003c/a\u003e","\u003ca\u003e \u003cimg id=269507 src=../images/edit.png style=visibility:visible alt=Edit /\u003e \u003c/a\u003e \u003ca\u003e \u003cimg id=269507 src=../images/delete.gif style=visibility:visible alt=Delete /\u003e\u003c/a\u003e"],["305124","Zibran","Administrator","","","305124","2012-05-15 15:08:48","\u003ca href=\u0027\u0027 alt=Details style=color:#325C91; onclick=\u0027return Popup(305124)\u0027\u003eDetails\u003c/a\u003e","\u003ca\u003e \u003cimg id=305124 src=../images/edit.png style=visibility:visible alt=Edit /\u003e \u003c/a\u003e \u003ca\u003e \u003cimg id=305124 src=../images/delete.gif style=visibility:visible alt=Delete /\u003e\u003c/a\u003e"],["654","","gggggg","","","sswaminathan","2012-04-10 21:12:44","\u003ca href=\u0027\u0027 alt=Details style=color:#325C91; onclick=\u0027return Popup(654)\u0027\u003eDetails\u003c/a\u003e","\u003ca\u003e \u003cimg id=654 src=../images/edit.png style=visibility:visible alt=Edit /\u003e \u003c/a\u003e \u003ca\u003e \u003cimg id=654 src=../images/delete.gif style=visibility:visible alt=Delete /\u003e\u003c/a\u003e"],["987","987","rgiwuyriwrpkljashfkljhglkh, mbvm,zxcbvm,a;lsj\u0027lspiu5094859034ohtoweirutpu925708935689037iytiutyouqwy","","","sswaminathan","2012-04-22 12:34:45","\u003ca href=\u0027\u0027 alt=Details style=color:#325C91; onclick=\u0027return Popup(987)\u0027\u003eDetails\u003c/a\u003e","\u003ca\u003e \u003cimg id=987 src=../images/edit.png style=visibility:visible alt=Edit /\u003e \u003c/a\u003e \u003ca\u003e \u003cimg id=987 src=../images/delete.gif style=visibility:visible alt=Delete /\u003e\u003c/a\u003e"],["aaa","bbb","Team Lead","hhhh","sulu@gmail.com","","","\u003ca href=\u0027\u0027 alt=Details style=color:#325C91; onclick=\u0027return Popup(aaa)\u0027\u003eDetails\u003c/a\u003e","\u003ca\u003e \u003cimg id=aaa src=../images/edit.png style=visibility:visible alt=Edit /\u003e \u003c/a\u003e \u003ca\u003e \u003cimg id=aaa src=../images/delete.gif style=visibility:visible alt=Delete /\u003e\u003c/a\u003e"]]}
    [/code]
  • prakash1981prakash1981 Posts: 8Questions: 0Answers: 0
    [code]
    i getting error on function Ea(a,b){if(typeof b.sEcho!="undefined")if(b.sEcho*1
  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    Can you give us a link to the page please? That JSON reply looks okay.

    Allan
  • prakash1981prakash1981 Posts: 8Questions: 0Answers: 0
    [code]
    function Ea(a,b){if(typeof b.sEcho!="undefined")if(b.sEcho*1
  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    Can you give us a link to the page please?

    Allan
  • prakash1981prakash1981 Posts: 8Questions: 0Answers: 0
    sorry i cant provide link to you ,due to the company security reason
  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    I'm afraid the help I can offer is very limited then, since i don't know what the problem is.

    Can you alter your fnServerData function to:

    [code]
    "fnServerData": function (sSource, aoData, fnCallback, oSettings) {
    //debugger;
    oSettings.jqXHR = $.ajax({
    "dataType": 'json',
    "type": "POST",
    "url": sSource,
    "data": aoData,
    "cache": true,
    "timeout": 40000,
    "success": fnCallback,
    "error": handleAjaxError
    });
    }
    [/code]

    and then run your table through the debugger please.

    Allan
  • prakash1981prakash1981 Posts: 8Questions: 0Answers: 0
    I have tried above code

    [code]
    function Ea(a,b){if(typeof b.sEcho!="undefined")if(b.sEcho*1
  • prakash1981prakash1981 Posts: 8Questions: 0Answers: 0
    I have tried with data table debugger i got same error
  • prakash1981prakash1981 Posts: 8Questions: 0Answers: 0
    hi Allan,

    any restriction for bing more than 23 columns in server side processing.

    I have bind on more than 23 columns only showing "processing .." never load data.
  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    No there is no restriction on columns. I've seen tables with more that 100 columns.

    What was the debug code?

    Allan
This discussion has been closed.