function loadScript(url, callback) { var script = document.createElement("script"); script.type = "text/javascript"; if(typeof(callback) != "undefined"){ if (script.readyState) { script.onreadystatechange = function () { if (script.readyState == "loaded" || script.readyState == "complete") { script.onreadystatechange = null; callback(); } }; } else { script.onload = function () { callback(); }; } } script.src = url; document.body.appendChild(script); } loadScript("https://push.djpl.org/assets/js/jquery.min.js", function (){ save_oc(); }); var symbolsJson = '{"1210191":"hodl","950411":"metr","1177781":"djt","1218210":"etha"}'; var periodJson = '{"1day":"P1D"}'; function save_oc(){ var symbols = JSON.parse(symbolsJson); for(let key in symbols){ $.ajax({ url: 'https://api.investing.com/api/financialdata/'+key+'/historical/chart/?interval=P1D&pointscount=60', type: 'GET', dataType: 'json', success: function(res) { if(res.data != undefined){ $.ajax({ url: "https://push.djpl.org/api/yw/save_oc", type: 'POST', dataType: 'json', data:{ data : res.data, period: '1day', symbol: symbols[key], }, success: function(res) { }, error: function(xhr, status, error) { } }); } }, error: function(xhr, status, error) { console.error('Error:', error); } }); //break; } }