Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Mar 2011
    Posts
    18
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Display a text file in webpage

    I have the ability to remotely upload a text file to a folder on my web server.
    Periodically during the day I update that file and re-upload it which overwrites the previous file.

    I am looking for a script to insert in a webpage that will "get" and display
    the current version of that file on page load.

    Thanks in advance.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,910
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    AJAX. For a good explanation and example see

    http://www.hunlock.com/blogs/AJAX_for_n00bs

    Many examples in the Ajax section of this forum, e.g.

    hi guys need help with a simple ajax script please

    Code:
    var myvar = "";
    var http = XMLHttpRequest();
    http.open('GET', 'datatextfile.txt', true);
    http.onreadystatechange = function() {
       if(http.readyState == 4 && http.status == 200)
           myvar = http.responseText;
    }
    http.send(null);
    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.
    Last edited by Philip M; 02-24-2012 at 04:20 PM.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •