I'm trying to display the data for "total_txs" from this URL https://www.chain.so/api/v2/address/DOGE/DK1i69bM3M3GutjmHBTf7HLjT5o3naWBEk
I've put together the following but the div is blank. (Forgive me if its painfully simple to see what I'm doing wrong)
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script>
$.getJSON("https://www.chain.so/api/v2/address/DOGE/DK1i69bM3M3GutjmHBTf7HLjT5o3naWBEk", function(data) {
$('#totaldonations').text(data.total_txs);
});
</script>
<div id="totaldonations"></div>
data
further contains a key nameddata
, under which your desired attribute lies. So you need to extract the value asdata.data.total_txs
.See the working demo below:
To avoid any confusion, rename the callback argument to
response
, so the key becomesresponse.data.total_txs
, which makes much more sense.