Newbie here on javascript and CSS, and I wanna know if it's possible to extract data from a .txt file and transform it to text and print on the page.
I was searching through some old topics, and did find some similiar questions, and I tried to copy but didn't work hahha
Here it is what I did try:
HTML:
<div id="printed"></div>
Script:
var text_print = new XMLHttpRequest();
text_print.open("GET", "folder/file.txt", true);
text_print.send();
text_print.onload = function (){
console.log( text_print.responseText.slice(0, text_print.responseText.indexOf("
")) ); };
document.getElementById("printed").innerHTML=text_print;
The .txt file has only one line of text, btw.
Thank you.