Invalid JSON response error

Invalid JSON response error

sarthaks21sarthaks21 Posts: 41Questions: 8Answers: 0

I read the data for datatable from a json file. That json file is updated every 5 seconds or so by a python script. Sometimes, I get the alert message Invalid JSON response. I think it's because the file is being accessed by python at the moment.
Is there any way to prevent this?
Thanks in advance!

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,172Questions: 26Answers: 4,923

    The first thing to do is to follow the steps in the Technote link provided in the error:
    https://datatables.net/manual/tech-notes/1

    You need to determine why you are getting the Invalid JSON response. Could be an error message or something else. Let us know what you find.

    Kevin

  • sarthaks21sarthaks21 Posts: 41Questions: 8Answers: 0
    edited June 2020

    @kthorngren As I mentioned in the question, the error is generated when the web-page reads the json during the python script is writing in it. Is there a way a lock or semaphore can be implemented or even a simple try catch that can prevent the website from reading the json while the python script is writing to it?
    Please ask if I'm not being clear
    Thanks!

  • kthorngrenkthorngren Posts: 21,172Questions: 26Answers: 4,923
    Answer ✓

    the error is generated when the web-page reads the json during the python script is writing in it

    How is the JSON file retrieved, via an Ajax request I suspect. It would be up to your server script to handle waiting for your Python script to return the data. This is not something that can be done on the client.

    Kevin

This discussion has been closed.