Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By sarahswansea

Thread: Accessing sections of large text file on server

  1. #1
    Junior Member
    Join Date
    Jul 2017
    Posts
    1
    Member #
    56982

    Accessing sections of large text file on server

    Hi, I am trying to understand the general idea of how to best accomplish this.

    I want to be able to have a large text file uploaded onto my website's server and then be able to access portions of the text file to display on my website. So basically, I should be able to start at the beginning of the text file and display, say, 500 words of text and then scroll down and the website will retrieve just enough of the text to make it seem like I am scrolling infinitely through the entire document. This seems to me similar to how facebook and twitter work? You scroll down through the feed and retrieve new data as needed. And I also want to be able to jump around through the document to access any chapter or page for example.

    I'm familiar in general with things like AJAX and node.js to communicate with the server but I'm not quite sure if I am going in the right direction or if there is some other technology I should be looking at. Or am I making this out to be too complicated? I'm just not sure so thanks for any help!

  2.  

  3. #2
    Junior Member SoftLink's Avatar
    Join Date
    Sep 2017
    Location
    Central Florida
    Posts
    24
    Member #
    57480
    It looks like you've got the right idea, AJAX. Write a function that is triggered on scroll. Retrieve a 'block' of data and display it at the bottom of the page.

    -----------------------------------------------------------------------------------------------------------------------
    Business Software • Database • Internet • Websites
    Web Designers: Need some heavy lifting done?
    SoftLink Systems

  4. #3
    Senior Member sarahswansea's Avatar
    Join Date
    Oct 2015
    Location
    Swansea, UK
    Posts
    152
    Member #
    52184
    Liked
    64 times
    If your server supports it, HTTP Range Requests would be the ideal way to do this. Here's what an jQuery AJAX request to do this might look like:

    $(function() {
    $.ajax({
    url: 'test.txt',
    headers: {Range: "bytes=0-499"},
    success: function(data) { $('#results').html(data); }
    });
    });
    htmlcode likes this.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 09:22 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com