Replace inner html with text from an external file

Got it!

var txtFile = new XMLHttpRequest();
txtFile.open("GET", "${resourcesFolderName}/text.txt", true);
txtFile.onreadystatechange = function() {
  if (txtFile.readyState === 4) {  // Makes sure the document is ready to parse.
    if (txtFile.status === 200) {  // Makes sure it's found the file.
      allText = txtFile.responseText; 
      //lines = txtFile.responseText.split("\n"); // Will separate each line into an array
      var customTextElement = document.getElementById('textHolder');
customTextElement.innerHTML = txtFile.responseText;
    }
  }
}
txtFile.send(null);
1 Like