Invalid JSON response due to amount of data rather than rows?
Invalid JSON response due to amount of data rather than rows?
I am completely lost as to why I am receiving this error. It appears to only occur on tables which have an excessive amount of rows, but I can resolve the issue by reducing the amount of data on the columns of these rows.
I am using client side rendering and everything works just fine until row numbers exceed around 2300 rows, which should still be a small enough number to justify client-side rendering. My model is passing down values which appear to be correct.
I have a lot of columns, 23. If I change a couple of columns to have smaller strings (it doesn't matter which columns), the table renders successfully.
I haven't posted any code, but I'm wondering if anyone has come across a similar situation? I haven't found any discussion with the same issue.
Many Thanks
This question has an accepted answers - jump to answer
Answers
The place to start is with the troubleshooting steps in the link provided in the alert:
https://datatables.net/manual/tech-notes/1
Let us know what you find. If you still have difficulties maybe you can use the debugger to capture the response and post the code for the developers to take a look.
Kevin
Hi Kthorngren,
Thanks for the reply. I have troubleshoot using the manual given and chrome browser however, chrome does not appear to receive any response data. Perhaps this is the problem? I have ran my JSON data through a validator for a case which is erroring and the data is valid.
The only fix appears to be reducing the size of the strings passed down within the json data (these strings are no longer than ~100 characters each), although perhaps this is a red herring.
Using the Datatables debugger, I receive the error below:
debug.js:formatted:544 Uncaught TypeError: n.fn.dataTable.tables(...).iterator is not a function
at Object.fn (debug.js:formatted:544)
at Object.a.default [as common] (debug.js:formatted:277)
at HTMLDivElement.<anonymous> (debug.js:formatted:85)
at HTMLDivElement.dispatch (jquery?v=Mh7tihsQ1O0rTM0umTppNi6HpfnVDbQElKLnfJb_b1o1:1)
at HTMLDivElement.a.handle (jquery?v=Mh7tihsQ1O0rTM0umTppNi6HpfnVDbQElKLnfJb_b1o1:1)
Which occurs here on line 10:
If you see the response data when the Datatable works but not when you get the JSON data then it would seem the server is not sending response data. Have you verified the server actually sends the JSON data?
Where are you getting the JSON data to test from? The JSON data Datatables will use is what you see in the Chrome Dev Tools
Response
tab. If there is no response data then it is invalid. The data at the server might be valid JSON but it doesn't sound like its making it to the client. Are there any errors in the server log?Not sure about the error using the debugger.
Kevin
Hi Kevin,
You are right, it turned out that the server was not sending the response data. I am using ASP.Net MVC 4 and it turns out that in some cases the JavaScriptSerializer.MaxJsonLength property was being exceeded, causing the data not to be sent.
I had to add an override method to my controller which increased the value of the MaxJsonLength property (see a stack overflow solution: here).
Once this was added, everything started working!
Thanks a lot for your help,
Adam