Last active
August 29, 2015 14:02
-
-
Save ryandotsmith/2cb44e5b0442e321779f to your computer and use it in GitHub Desktop.
An example for how to authenticate against Chain using CORS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> | |
</head> | |
<body> | |
<p>Balance: <span id="balance"></span></p> | |
</body> | |
<script type="text/javascript"> | |
$(document).ready(function() { | |
var addr = window.location.hash.split('#').pop(); | |
var url = 'https://api.chain.com/v1/bitcoin'; | |
url += '/addresses/' + addr; | |
url += '?key=GUEST-TOKEN'; | |
$.ajax({ | |
url: url, | |
type: 'GET', | |
success: function(data) { | |
$('#balance').text(data.balance); | |
}, | |
error: function(req, msg, err) { | |
console.log(err); | |
} | |
}); | |
}); | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment