Automated Table from API
-
Target to make a table with data from api https://poloniex.com/public?command=returnTradeHistory¤cyPair=BTC_ETH )
It also needs to be updated automatically without updating the page. I can't figure out how to do this.
-
<table id="table-list"> <tr> <th>Type</th> <th>GlobalTradeID</th> <th>TradeID</th> <th>orderNumber</th> <th>Date</th> <th>Rate</th> <th>Total</th> </tr> </table>
function loadData() {
$.ajax({
url: 'https://poloniex.com/public?command=returnTradeHistory¤cyPair=BTC_ETH',
type: 'GET',
cache: false,
contentType: false,
processData: false,
error: function(req, text, error) {
alert(error);
},
success: function ( data ) {
if ( data && $.isArray(data) && data.length > 0 ) {
$('#table-list tr:not(:eq(0))').remove();
for (var i = 0; i < data.length; i++) {
$('#table-list tr:last-child').after('<tr>' +
'<td>' + data[i].type+'</td>'+
'<td>' + data[i].globalTradeID+'</td>'+
'<td>' + data[i].tradeID+'</td>'+
'<td>' + data[i].orderNumber+'</td>'+
'<td>' + data[i].date+'</td>'+
'<td>' + data[i].rate+'</td>'+
'<td>' + data[i].total+'</td>'+
'</tr>');
}
}
},
});
}$(document).ready(function(){
setInterval(function(){
loadData();
}, <кол-во секунд через которое произойдет обновление>);});