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

Link to comment
Share on other sites

True, although if you're only going use jQuery for this one thing you need to think whether it's worth the extra bandwidth of loading the entire framework.

The entire jQuery framework is only about 24KB (when compressed).

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.