I trying to read txt file in JS. So I am using this code.
My txt file looks: ["187.48.35.40"]
My application is searching IP adress on Google Map.
When i put in my code: var ip = ["187.48.35.40"];
My program works perfect but I want to open txt file with IP adres.
function readTextFile(file)
{
var rawFile = new XMLHttpRequest();
rawFile.open("GET", file, false);
rawFile.onreadystatechange = function ()
{
if(rawFile.readyState === 4)
{
if(rawFile.status === 200 || rawFile.status == 0)
{
var allText = rawFile.responseText;
alert(allText);
}
}
}
rawFile.send(null);
}
var ip = readTextFile("xxx.txt");
But my application can't read txt file.