Last active
June 15, 2019 10:11
-
-
Save bogdan-nourescu/07a370eb63b64428e2e170bd40d6e852 to your computer and use it in GitHub Desktop.
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
<html> | |
<head> | |
<script> | |
var ratesAzi=undefined; | |
var ratesIeri = undefined; | |
function cursValutar() { | |
var xhttp = new XMLHttpRequest(); | |
xhttp.onreadystatechange = function() { | |
if (this.readyState === 4) { | |
if(this.status == 200){ | |
ratesAzi=JSON.parse(this.responseText); | |
if(ratesIeri !==undefined){ | |
draw(); | |
} | |
}else{ | |
alert("a crapat"); | |
} | |
} | |
}; | |
xhttp.open("GET", "http://data.fixer.io/api/latest?access_key=bab6dc180ed5d2d17a7bd00df96ba187", true); | |
xhttp.send(); | |
} | |
function cursValutarIeri() { | |
var xhttp = new XMLHttpRequest(); | |
xhttp.onreadystatechange = function() { | |
if (this.readyState === 4) { | |
if(this.status == 200){ | |
ratesIeri=JSON.parse(this.responseText); | |
if(ratesAzi !==undefined){ | |
draw(); | |
} | |
}else{ | |
alert("a crapat"); | |
} | |
} | |
}; | |
xhttp.open("GET", "http://data.fixer.io/api/latest?access_key=bab6dc180ed5d2d17a7bd00df96ba187", true); | |
xhttp.send(); | |
} | |
function draw(){ | |
var str = ""; | |
for(var i in ratesAzi.rates){ | |
str += `<li>${i} - ${ratesAzi.rates[i]} - ${ratesIeri.rates[i]}</li>`; | |
} | |
document.getElementById("listaBNR").innerHTML=str; | |
} | |
</script> | |
</head> | |
<body onload="cursValutar();cursValutarIeri();"> | |
<ul id="listaBNR"> | |
<li>RON - 4.75</li> | |
</ul> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment