I would like to display multiple JSON feed in a HTML table. With one source my code is working well. But how can I load multiple feed to my table?
Also I would like to know where can I insert tags to have table header after generate the table?!
My code:
<body>
<section>
<h1>Big Flower profit calculator</h1>
<script>
$(document).ready(function () {
var proxy = "https://api.allorigins.win/get?url=";
var MyURL1 = "https://whattomine.com/coins/151.json?hr=505.0&p=1800.0&fee=0.0&cost=0.12&hcost=0.0&span_br=1h&span_d=24";
var MyURL2 = "https://whattomine.com/coins/321.json?hr=2100.0&p=430.0&fee=0.0&cost=0.12&hcost=0.0&span_br=1h&span_d=24";
var MyURL3 = "https://whattomine.com/coins/334.json?hr=3200.0&p=410.0&fee=0.0&cost=0.12&hcost=0.0&span_br=&span_d=24";
var MyURL4 = "https://whattomine.com/coins/164.json?hr=350.0&p=324.0&fee=0.0&cost=0.12&hcost=0.0&span_br=&span_d=24";
let list = [];
var res = '';
var table = $("<table id=DynamicTable border=1></table>").appendTo("#ResultArea");
// FETCHING DATA FROM JSON FILE
$.getJSON(proxy + MyURL1,
function (data) {
console.log(data);
var adat = data.contents;
console.log(adat);
// CONVERT JSON
res = JSON.parse(data.contents)
list.push(res);
console.log(list);
$.each(list, function (i, value) {
//Create new row for each record
var row = $("<tr></tr>").appendTo(table);
$("<td></td>").text(value.tag).appendTo(row);
$("<td></td>").text(value.difficulty).appendTo(row);
$("<td></td>").text(value.difficulty24).appendTo(row);
$("<td></td>").text(value.revenue).appendTo(row);
$("<td></td>").text(value.cost).appendTo(row);
$("<td></td>").text(value.profit).appendTo(row);
});
});
});
</script>
</section>
<div id="ResultArea"></div>