Can't Get Simple Ajax with JSON Object Data To Work
Can't Get Simple Ajax with JSON Object Data To Work
Siddhanathaswami
Posts: 2Questions: 1Answers: 0
Aloha,
I'm trying to get a simple DataTable to work from JSON data.
See example: https://jsfiddle.net/Siddhanathaswami/1or4k3z8/9/
The data is in this format:
[{"EMB":68,"FirstName":"John"},{"EMB":488,"FirstName":"Jane"}]
The section in the manual here (http://datatables.net/manual/ajax) under the title "Data array location" seems the closest to what I and doing.
I have to be missing something simple.
Any help/tips hugely appreciated.
This discussion has been closed.
Answers
The JSFiddle example won't work because your source data is http while JSFiddle there is https (the browser refuses to load insecure content on a secure page - it tells you this in its console).
Even if you change the protocols to match, it doesn't work due to cross site scripting protection.
However, it should work on a local page as far as I can see.
Allan
Actually, if Siddha could implement HTTPS on the server that generates the Json output, and add the "Access-Control-Allow-Origin: jsfiddle.net" header to the generated Json response, it would work well Allan. An example that uses a different external source:
https://jsfiddle.net/awlex/sqnqyqbr/3/
Yup - that'd do it as well. JSFiddle works without https so you don't even need to implement https support on the target server.
Allan
Thanks! I knew it was something super simple. I should have looked at the console...Oops.