Need to convert bitcoin address function from php to Jquery

0 votes

I want to convert this function from php to JQuery. I tried a few things but I am not able to get it right

<?php
function getBalance($adress) {
    return file_get_contents('https://blockchain.info/de/q/addressbalance/'. $adress);
}

$addy1_balance = getBalance('19F16Tg47PUsie2vNzkjJn5xsgjAPU3z2f') / 100000000;
$addy2_balance = getBalance('17jJBRxVdNX4uP2gjs5t9LEMJ56zAXK7iC') / 100000000;
$addy3_balance = getBalance('13FBnfCFvJmketncTwr2csXJrzwU4wPLqe') / 100000000; 
$addy4_balance = getBalance('17tGnUhPNTF1L2NpfmmKWLFQS5teRGJSaf') / 100000000; 

?>


echo $addy1_balance;
echo $addy2_balance;
echo $addy3_balance;
echo $addy4_balance;
Sep 5, 2018 in Blockchain by slayer
• 29,050 points
44 views

1 answer to this question.

0 votes

Use AJAX. It will be easier to use a library like jQuery. With jQuery you can use jQuery.getJSON. It only works if blockchain.info allow cross domain call.

jQuery.getJSON('https://blockchain.info/de/q/addressbalance/17jJBRxVdNX4uP2gjs5t9LEMJ56zAXK7iC', function(result) {
alert(result);
});
answered Sep 5, 2018 by digger
• 26,550 points

Related Questions In Blockchain

0 votes
1 answer

Is there a way to send funds from a specific bitcoin address in a wallet?

I'll answer my own question, It was unbelievably ...READ MORE

answered Sep 3, 2018 in Blockchain by Perry
• 17,020 points
68 views
+2 votes
1 answer
0 votes
1 answer

How can I retrieve to and from address in transaction directly from blockchain?

The spending conditions, i.e., who is able ...READ MORE

answered Jul 11, 2018 in Blockchain by Shashank
• 10,350 points
69 views
0 votes
1 answer

Is it possible to claim Bitcoin Cash from an exchange that does not support it?

You can't claim BCH without knowing private ...READ MORE

answered Jul 17, 2018 in Blockchain by ariaholic
• 7,340 points
38 views
+1 vote
3 answers

Removing double quotes from a string from JSON response in PHP

Just remove the json_encode call, and it should work: $resp ...READ MORE

answered Sep 12, 2018 in Blockchain by digger
• 26,550 points
3,070 views
0 votes
1 answer

How to create Bitcoin Address in PHP?

You need to understand that Bitcoin address and ...READ MORE

answered Aug 27, 2018 in Blockchain by Perry
• 17,020 points
439 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
141 views
0 votes
1 answer

How to extract h160 address of bitcoin blockchain?

You can extract the data using the ...READ MORE

answered Jul 16, 2018 in Blockchain by digger
• 26,550 points
121 views
0 votes
1 answer

Cant Decode Bitcoin Base58 address to byte array

In your for-loop: for (int k = b256.Length ...READ MORE

answered Aug 21, 2018 in Blockchain by digger
• 26,550 points
93 views