ajax获取对象数据 并且吧数组的某个值全部相加
$.ajax({
url: "https://api.gopluslabs.io/api/v1/token_security/56?contract_addresses=0x49d3ce635a88dFc994DeaE10c7f99F2842626b6B",
type: "GET",
//data: { "contract_addresses": tokenAddr },
dataType: "json",
success: function (data) {
console.log(data.result);
var key = Object.keys(data.result)[0];
var tokenData = data.result[key];
//基本信息
var owner_address=tokenData.owner_address.slice(0,4)+"..."+tokenData.owner_address.slice(38);;
$('#owner_address').html(owner_address);//拥有者地址
var total_supply=parseFloat(tokenData.total_supply).toFixed(2);
$('#total_supply').html(total_supply);//总供应量
$('#token_name').html(tokenData.token_name);//token名称
$('#token_symbol').html(tokenData.token_symbol);//token符号
//交易&流动性
var buy_tax=parseFloat(tokenData.buy_tax*100).toFixed(0);
$('#buy_tax').html(buy_tax+"%");//买入费
var sell_tax=parseFloat(tokenData.sell_tax*100).toFixed(0);
$('#sell_tax').html(sell_tax+"%");//卖出费
//持币信息
$('#holder_count').html(tokenData.holder_count);//token持有人数
var holders = "";
for(var i = 0;i < tokenData.holders.length; i++){
var kyes=i+1;
var address=tokenData.holders[i].address;
//var addressSi = "0x000000000000000000000000000000000000dead";
var addressSuoduan=address.slice(0,4)+"..."+address.slice(38);
var balance=parseFloat(tokenData.holders[i].balance).toFixed(2);
var percent=parseFloat(tokenData.holders[i].percent*100).toFixed(2);
var is_locked=tokenData.holders[i].is_locked;
var is_contract=tokenData.holders[i].is_contract;
if(is_locked == 1){
holders+='' +kyes+'. '+addressSuoduan+''+balance+'('+percent+'%)';
}else if(is_contract == 1){
holders+='' +kyes+'. '+addressSuoduan+''+balance+'('+percent+'%)';
}else{
holders+='' +kyes+'.'+addressSuoduan+''+balance+'('+percent+'%)';
}
}
$('#holders').html(holders);
},
});