The code below is to write a simple text file reader by creating a function that takes in the file’s path and to convert each line of text into a char array.
function readTextFile() { var rawFile = new XMLHttpRequest(); rawFile.open("GET", "testing.txt", true); rawFile.onreadystatechange = function() { if (rawFile.readyState === 4) { var allText = rawFile.responseText; document.getElementById("textSection").innerHTML = allText; } } rawFile.send(); }
I’m getting the error XMLHttpRequest exception 101.
It works on Firefox, but it fails to run on Google chrome and gives me the exception 101. Can anyone tell me how can I get this work on other browsers as well (Especially Chrome)?