I’m using the following code to read a local text file from a local Javascript file, but it isn’t working:
var txtFile = new XMLHttpRequest();
txtFile.open('GET', fileLocation, true);
The error I get:
XMLHttpRequest cannot load file:///C:/File.txt. Cross origin requests are only supported for HTTP.
Any ideas?
You can not access local resources from javascript,
You should put this file in your site and try to access it via fileLocation like http://mywebsite/File.txt