Remote debugging for JSON parse error

Remote debugging for JSON parse error

mathiemathie Posts: 36Questions: 0Answers: 0
edited August 2011 in Plug-ins
Some visitors reported seeing the JSON parse error but it's not easy to replicate. Here is the code that will call a server-side script to record errors like this for developers to debug.

1) Around line 40 in jquery.dataTables.min.js:

this.fnServerData=function(a,b,c,d){d.jqXHR=i.ajax({url:a,data:b,success:c,dataType:"json",cache:false,error:function(f,e){if (e=="parsererror"){alert("Error: ....");debugDT(a,b,f.responseText);}}})};

2) And you can use this in your own extend JS file:

function debugDT(p1,p2,p3) {
$.post("jsRemoteDebug.php",{ url:p1,input:p2,output:p3 } );
}

3) Of course you would need to write your own jsRemoteDebug to collect and record the params.

Hopefully this is useful
Son Nguyen
This discussion has been closed.