text.txt
с каким-то текстом."text.txt"
<p class="boris"></p>
function show(x) {
return x;
}
document.querySelector(".boris").innerHTML = show("text.txt");
<input type="file" id="inputfile" accept=".txt">
<textarea id="output"></textarea>
inputfile.addEventListener('change', function() {
var file = this.files[0],
reader = new FileReader;
reader.onloadend = function(evt) {
output.value = reader.result;
};
reader.readAsText(file);
}, false);
xhr = new XMLHttpRequest;
xhr.open('GET', '/files/foo.txt', true);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
xhr.onreadystatechange = null;
if (xhr.status == 200) {
output.value = xhr.responseText;
}
}
};
xhr.send(null);