If the element #the-json is empty it will cause this error:
Uncaught SyntaxError: Unexpected end of input
For the following code:
myJSON = JSON.parse($("#the-json").attr('value'));
How should this error be handled so it doesn’t stop the entire script working?
Use try-catch statement:
Or check before do something: