Need to convert bitcoin address function from php to Jquery

+1 vote

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,370 points
678 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,740 points

Related Questions In Blockchain

+1 vote
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,100 points
1,435 views
+2 votes
1 answer

how to convert hash160 to bitcoin address in python?

Hey @Raj. I use the following script. ...READ MORE

answered Jul 12, 2019 in Blockchain by Tanisha
3,754 views
0 votes
1 answer

(bitcoin) Calculate hash from getwork function - how to do it?

This is correct as there is a ...READ MORE

answered Feb 28, 2022 in Blockchain by Soham
• 9,710 points
721 views
+1 vote
0 answers

How to check a Bitcoin wallet balance from first generated address (m/44'/0'/0'/0/0)

Is there a way to check a ...READ MORE

Mar 4, 2022 in Blockchain by Soham
• 9,710 points
2,243 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,740 points
45,258 views
0 votes
1 answer

How to create Bitcoin Address in PHP?

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

answered Aug 28, 2018 in Blockchain by Perry
• 17,100 points
5,470 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
1,936 views
0 votes
1 answer

How do I add multiple recipients for transactions via Blockchain API?

Convert the recipes into JSON objects. x = ...READ MORE

answered Jul 6, 2018 in Blockchain by Perry
• 17,100 points
903 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,740 points
2,562 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,740 points
1,386 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP