<button type="button" onclick="loadDoc()">Scimba text</button>
<script>
function loadDoc() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
for (var i = 1; i<5; i++){
if (xhttp.readyState == 4 && xhttp.status == 200) {
document.getElementById(i).innerHTML = xhttp.responseText;
}
}
};
xhttp.open("GET", "info1.txt", true);
xhttp.send();
}
</script>
Hello everybody ! Need some help ... How can I make the for loop to iterate one time when I click the button and when the button is clicked for the second time the loop will iterate also the second time and so on ...?