Answer the question
In order to leave comments, you need to log in
How to get json file via javascript?
Hello.
It used to be somehow easier to get json files by reference, now it feels like something has changed.
Does not want to work, does not transmit anything, information 0 (zero), via console.log() and via alert()
sends NOTHING. Not even undefanted. Full zero. What is the problem and why it stopped working I do not understand.
If there is any other way - tell me. PHP is not suitable.
Here is the code itself that stopped working:
<!doctype>
<html lang="ru">
<head>
<meta charset="utf-8">
<title>Веб-страница</title>
<script>
function loadJSON(callback) {
var xobj = new XMLHttpRequest();
xobj.overrideMimeType("application/json");
xobj.open('GET', 'https://bittrex.com/api/v1.1/public/getmarketsummary?market=BTC-GBG', true);
xobj.onreadystatechange = function () {
if (xobj.readyState == 4 && xobj.status == "200") {
callback(xobj.responseText);
}
};
xobj.send(null);
}
function init() {
loadJSON(function(response) {
var actual_JSON = JSON.parse(response);
document.getElementById("data").innerHTML = actual_JSON.result[1].MarketName + " / " + actual_JSON.result[1].BaseVolume;
});
}
</script>
</head>
<body>
<h1>Заголовок</h1>
<div id="data"></div>
</body>
</html>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question