I'm trying to pull the following JSON data from a local file into DataTables, but getting an invalid JSON
response:
{
"data": [
{
"accountNumber": "2423",
"domain": "domain.com",
"playerClass": "",
"adTag": ""
},
{
"level": "info",
"message": "generator ",
"timestamp": "2015-06-10T15:59:02.803Z"
}
]
}
Using:
$(document).ready(function () {
$('#content').dataTable({
"ajax": 'test.log'
});
});
It's because you do in fact have invalid JSON. When using datatables, according to the documentation, your data source always needs to be an array: https://www.datatables.net/manual/data
Here is what it should look like:
When you create JSON, you should always validate it to make sure it is valid - check out http://jsonlint.org