Failed to load https://www.bitstamp.net/api/v2/ticker/btcusd: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.function retrieveBitstampLatestPrice() {
console.log('retrieveBitstampLatestPrice');
var xhr_method = 'GET';
var xhr_url = 'https://www.bitstamp.net/api/v2/ticker/btcusd';
var xhr_send = null;
var xhr = new XMLHttpRequest();
xhr.open(xhr_method, xhr_url, true);
xhr.send(xhr_send);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
var response = JSON.parse(xhr.response);
//console.log(response);
bitstampLatestPrice = response.last;
} else {
console.log('Something went wrong! (' + xhr_url + ')');
console.log(xhr);
}
}
}
}
برچسب:
نویسنده: آیلین رضوانی