JSON loading error

JSON loading error

marianidiegomarianidiego Posts: 54Questions: 17Answers: 1

Link to test case:
I'm using this: https://editor.datatables.net/examples/advanced/parentChild.html

Description of problem:
When I press on row of first table, sometimes an error (altert) of wrong JSON is generated.

1) I would like it to remove that annoying error message via altert (I have 8 tables as children, and therefore I get it 8 times, and that doesn't make me very happy....). Is that possible?

2) I would like to handle the error. I haven't found the cause yet, but the error comes at randomo moments, and a second attempt works. Maybe it is a network problem. Either way, I would like to handle it so that it doesn't crash all the way through, but the user can have more convenient navigation. Ideally, if at the JSON error retries the download up to a maximum of 3 times 3 seconds apart. Would this be possible?

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin

    Do you get that error on the page you linked to? I've just tried clicking around on it and haven't seen it.

    The proper answer is to never let the server return anything other than valid JSON. However, if you want to handle the error yourself you can do so using the errMode parameter and provide your own error handler.

    There is no way for DataTables to do a retry itself. You would need to use ajax as a function and implement that yourself if that is a requirement.

    Allan

  • marianidiegomarianidiego Posts: 54Questions: 17Answers: 1

    No, not on your page -- but on my site.

    As mentioned, this is a communication error. Normally AJAX returns Error 500.

    Do you have an example of how to use errMode?

    Regards

    Diego

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin

    You've probably just missed the example - its at the bottom of the page I linked to.

    Allan

Sign In or Register to comment.