Invalid JSON response
Invalid JSON response
razvan
Posts: 11Questions: 3Answers: 0
Hi,
I get this message for the following JSON. I first fetch the JSON in a variable (e.g. list) then use that as "data": list.
{"people":[{"Id":"2","firstname":"John","lastname":"Doe"},{"Id":"3","firstname":"Milan","lastname":"Jovovic"},{"Id":"4","firstname":"John","lastname":"Neumann"}]}
Can you tell why is this not valid?
Best Regards,
Razvan
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
That is valid - so there must be something else in the response which is making it not valid.
Allan
Thanks for the reply Allan. When I use "url" parameter for ajax it works:
"ajax": {
"url": jsonPeopleURL,
//"data": peopleData,
"dataSrc": "people"
},
But when I try to get the Json first and save it in a local variable like this
});
and then use
"ajax": {
//"url": jsonPeopleURL,
"data": peopleData,
"dataSrc": "people"
},
It doesn't.
So I need to save the DataTables Json in a variable so I can use it later. Do you have any suggestions how I can do this? The approach from above should've normally worked, it's the same datasource.
Thanks!
Best Regards,
Razvan
It's wouldn't You don't need to use
ajax
for that since you aren't Ajax fetching the data (as far as DataTables can see). Use thedata
option if you just want to pass data in that you already have.Allan
Thanks Allan. You're right, ajax was left there for some reason and it's not needed since this uses the client data.