Created
June 4, 2021 11:14
-
-
Save eliandoran/161a6a020ebb602d479ce2558cbdec67 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
<!DOCTYPE | |
<html> | |
<body> | |
<label>Curs valutar</label> | |
<input id="exchange-rate" type="text" disabled /> | |
<button id="update-button">Update</button> | |
<script> | |
var URL = "http://www.infovalutar.ro/bnr/azi/eur"; | |
var updateButtonEl = document.getElementById("update-button"); | |
var exchangeRateTextEl = document.getElementById("exchange-rate"); | |
updateButtonEl.onclick = function() { | |
var xhttp = new XMLHttpRequest(); | |
xhttp.onreadystatechange = function() { | |
if (this.readyState !== 4) { | |
// Not yet ready. | |
return; | |
} | |
if (this.status === 200) { | |
const responseText = xhttp.responseText; | |
exchangeRateTextEl.value = responseText; | |
} else { | |
alert("Eroare la preluarea datelor."); | |
} | |
}; | |
xhttp.open("GET", URL, true); | |
xhttp.send(); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment