Jump to content

Get content from txt file


Omirion

Recommended Posts

please some google..

 

var txtFile = new XMLHttpRequest();
txtFile.open("GET", "http://my.remote.url/myremotefile.txt", true);
txtFile.onreadystatechange = function() {
  if (txtFile.readyState === 4) {  // Makes sure the document is ready to parse.
    if (txtFile.status === 200) {  // Makes sure it's found the file.
      allText = txtFile.responseText;
      lines = txtFile.responseText.split("\n"); // Will separate each line into an array
    }
  }
}
txtFile.send(null);

 

http://social.msdn.microsoft.com/Forums/en-US/sidebargadfetdevelopment/thread/64ea2d16-7594-400b-8b25-8b3b9a078eab

What ceycey's suggesting you use is AJAX, by the way. This article explains it better, and the example he talks you through is to load a text file:

 

http://www.openhosting.co.uk/articles/webdev/5899/

 

Very useful article just what i needed actually.

 

10x for the suggestions guys. jQuery is an option but I'm running on a tight KB limit, and I've already made my own animation code so not worth it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.