I need to load a text file in js, the text file is in the same dir as the .js file.
I found this code
var file = new XMLHttpRequest()
file.open("GET", "file.txt", true)
file.send()
file.onreadystatechange = function () {
if (file.readyState == 4 && file.status == 200) {
console.log(file.responseText)
}
}
But that doesn't work if I open my site locally ("file:///C:/site.html")
How can I load a text if it is run locally? (Without using JQuery)
EDIT
I do not want to use JQuery but these are some questions with using JQuery.
"Ajax in Jquery does not work from local file" or "Jquery load() only working in firefox?"