I have code like this:
<script>
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if(xhr.readyState === 4 && xhr.status === 200) {
var data = JSON.parse(xhr.responseText);
var ex_rate = data["market_price_usd"];
document.getElementById('btcusd777').innerHTML = ex_rate;
}
};
xhr.open('GET', 'https://blockchain.info/ru/stats?format=json');//&cors=true doesn't help
xhr.send();
</script>
1 BTC = <span id="btcusd777"></span> USD
But it doesn't work because api is on different domain. Is there a way to fix it somehow? I don't want to use jquery