title: For loop onclick button
body: <pre><code>&lt;button type="button" onclick="loadDoc()"&gt;Scimba text&lt;/button&gt;
  
  &lt;script&gt;
  function loadDoc() {
    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
      for (var i = 1; i&lt;5; i++){
        if (xhttp.readyState == 4 &amp;&amp; xhttp.status == 200) {
          document.getElementById(i).innerHTML = xhttp.responseText;
        }
      }
    };
    xhttp.open("GET", "info1.txt", true);
    xhttp.send();
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>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 ...?</p>