How to handle no returned JSON via ajax
How to handle no returned JSON via ajax
budfrogs
Posts: 1Questions: 1Answers: 0
I am using servlet to query a database that sometimes will return no information. If I return null I get an invalid JSON response.
Considering there was no data in the database null is valid. How do you handle no returned data or provide a response to DataTables in a JSON format that you can intercept and display a different message in the table?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
null
might be valid from the database, but it isn't valid JSON. Try typing "null" into JSONLint.For DataTables, when there are no records to display, you should pass it an empty array - e.g.:
(assuming you are using the default
data
property).Allan