Can't Get Simple Ajax with JSON Object Data To Work

Can't Get Simple Ajax with JSON Object Data To Work

SiddhanathaswamiSiddhanathaswami 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.

Answers

  • allanallan Posts: 62,024Questions: 1Answers: 10,167 Site admin

    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

  • AlexKersAlexKers Posts: 1Questions: 0Answers: 0

    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/

  • allanallan Posts: 62,024Questions: 1Answers: 10,167 Site admin

    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

  • SiddhanathaswamiSiddhanathaswami Posts: 2Questions: 1Answers: 0

    Thanks! I knew it was something super simple. I should have looked at the console...Oops.

This discussion has been closed.