Invalid JSON response due to amount of data rather than rows?

Invalid JSON response due to amount of data rather than rows?

AdD959AdD959 Posts: 3Questions: 1Answers: 0

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

  • kthorngrenkthorngren Posts: 21,344Questions: 26Answers: 4,954

    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

  • AdD959AdD959 Posts: 3Questions: 1Answers: 0

    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:

    10: [function(e, t, a) {
            "use strict";
            Object.defineProperty(a, "__esModule", {
                value: !0
            }),
            e("../lib").createTest("Bootstrap and DataTables styling both loaded", function(n) {
                var s = [];
                return n.fn.dataTable && n.fn.dataTable.tables({
                    api: !0
                }).iterator("table", function(e, t) {
                    if (n(this.table().container()).hasClass("dt-bootstrap4")) {
                        var a = n("div.paginate_button").css("padding-left");
                        a && 0 !== parseInt(a, 10) && s.push({
                            table: e.nTable.id,
                            level: "error",
                            msg: 'It appears that both DataTables and DataTables/Bootstrap integration styling have been loaded on your page. This will result in visual errors such as two different ordering icons in the table header and widely spaced pagination buttons. Only one of the DataTables styling packages should be loaded - in this case likely the DataTables/Bootstrap integration. Use <a href="https://datatables.net/download">the download builder</a> to ensure that you get the files you need.'
                        })
                    }
                }),
                s
            })
    
  • kthorngrenkthorngren Posts: 21,344Questions: 26Answers: 4,954
    Answer ✓

    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?

    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?

    I have ran my JSON data through a validator for a case which is erroring and the data is valid.

    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

  • AdD959AdD959 Posts: 3Questions: 1Answers: 0

    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

This discussion has been closed.