Possible Duplicate:
Reading a txt file from Javascript
I need to open and read the contents of a txt file using JavaScript. How can I do this?
Possible Duplicate:
Reading a txt file from Javascript
I need to open and read the contents of a txt file using JavaScript. How can I do this?
On a remote server you'd just use an XMLHttpRequest object to retrieve the data and access it.
var request = new XMLHttpRequest();
request.open('GET', URL TO FILE);
request.onreadystatechange(function(){
if(request.readyState === 4 && request.statusCode === 200){
console.log(request.responseText);
}
});
request.send();
That will fail in IE7, 8 and probably 9.
If you're trying to read from local disk, you're going to have a bad time.