showing results for - "read text file in vanilla js"
Edoardo
18 Jan 2016
1function readTextFile(file)
2{
3    var rawFile = new XMLHttpRequest();
4    rawFile.open("GET", file, false);
5    rawFile.onreadystatechange = function ()
6    {
7        if(rawFile.readyState === 4)
8        {
9            if(rawFile.status === 200 || rawFile.status == 0)
10            {
11                var allText = rawFile.responseText;
12                alert(allText);
13            }
14        }
15    }
16    rawFile.send(null);
17}
18