|
|
how to read a file in javascript? - Javascript
|
Views : 1729
|
|
Tagged in : Javascript
|
|
|
Report This Scrap as Inappropriate We request you to choose the appropriate categroy and subcategory that suits your
objectionable concern about the scrap, So that our team can review and find out whether it violates our Guidelines or the
scrap is not suitable for all viewers.
|
Read a file in javascript:
To read a file and store the values of a file into a variable, use the following,
var txtFile = new XMLHttpRequest();
txtFile.open("GET", "http://your domain(or)path/domains.txt", true);
txtFile.onreadystatechange = function()
{
if (txtFile.readyState === 4) // Makes sure the document is ready to parse.
{
if (txtFile.status === 200)
{
allText = txtFile.responseText;
lines = txtFile.responseText.split("\n"); // Will separate each line into an array
}
}
} |
|
By Ramya, On - 2009-06-16 |
|
|
|