Supposing I have this external json:
<script id="data" src="https://website.com/datas.json"></script>
Created with this code:
window.onload = function () {
var e = document.createElement("script");
e.setAttribute("id", "data");
e.src = "https://website.com/datas.json";
document.getElementsByTagName("head")[0].appendChild(e);
}
How can I get this json content to parse it after ?
This is what I tried:
var data = JSON.parse(document.getElementById('data').innerHTML);
Thanks.