Invalid JSON for the first load

Invalid JSON for the first load

PandalexPandalex Posts: 32Questions: 8Answers: 1

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
DataTables warning: table id=tableau - Invalid JSON response. For more information about this error, please see https://datatables.net/tn/1
Description of problem:

Hello,

I can not reproduce my case so here is my symptoms:

My datatable loads a JSON through Ajax.

            ajax: {
                    dataType: 'json',
                    type: 'GET',
                    url: '/SpicmiValidation/ChargeSpicmi/',         // Servlet générant le Json qui sert de source de données au tableau
                    dataSrc : ''
                },

At the first load of my servlet I get the message:

DataTables warning: table id=tableau - Invalid JSON response. For more information about this error, please see https://datatables.net/tn/1
![](https://datatables.net/forums/uploads/editor/ds/2e0ooqticdnd.gif "")

When I reload, everything is fine, and for the next loads and as long as I don't reload the servlet or delete the sessions data I can navigate through the servlet with no issue, loading different data each time.

It's really the first time I access.

When I check the console I can see the JSON and it's the same the first time and when I reload.

This is very strange and I don"t know how I can debug or fix the issue.

Answers

  • kthorngrenkthorngren Posts: 20,993Questions: 26Answers: 4,887

    Have you tried the troubleshooting steps at the link in the error?
    https://datatables.net/tn/1

    Let us know what you find.

    Kevin

  • PandalexPandalex Posts: 32Questions: 8Answers: 1
    edited May 28

    Yes, I'm not sure if ti worked but I tried to add a GIF of the behaviour and the chrome console but I see it did not work.
    The JSON is the same the first time and when I reload

    Here is the gif again (it loops a bit to fast but when I reload you can see the data with the orange cell)

  • kthorngrenkthorngren Posts: 20,993Questions: 26Answers: 4,887
    edited May 28

    Its hard to see the JSON data in the GIF but it looks like it begins with ([ with an array of data then ends with )]. Which doesn't look valid to me. But again the image is to small to see exactly what is there. Did you follow the steps in the link and use jsonlint.com to validate the response?

    Can you post the failing response here so we can take a look?

    Kevin

  • PandalexPandalex Posts: 32Questions: 8Answers: 1

    Yes the JSON is valid.
    And I used WinMerge to make sure that it was the same for the first time and when I reload (it's the same).
    It's the same format that I use everywhere and apart from this very first load, it's working great.

    What do you call the 'failing response' ?

  • kthorngrenkthorngren Posts: 20,993Questions: 26Answers: 4,887

    What do you call the 'failing response' ?

    You have a JSON response that is causing the Invalid JSON error. Please post the JSON response that is causing the error.

    Kevin

  • kthorngrenkthorngren Posts: 20,993Questions: 26Answers: 4,887

    Or better is a link to a test case replicating the issue so we can do some live debugging.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

Sign In or Register to comment.