jeudi 27 décembre 2018

Printing numbers in correct way

I'm getting data from 'http://p****.i*****.fi/food.txt' which is just numbers under each other like this, 1
2
3
4, but it prints those numbers next to each other like this 1 2 3 4, is there a way to print it as it is ?

function Doc() {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      document.getElementById("demo").innerHTML =
      this.responseText;
    }
  };
  xhttp.open("GET", "http://p****.i*****.fi/food.txt", true);
  xhttp.send();
}
<div id="demo">
<button type="button" onclick="Doc()">Content</button>
</div>

Aucun commentaire:

Enregistrer un commentaire