Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6097405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:02:22+00:00 2026-05-23T13:02:22+00:00

Is it possible to retrieve a txt files content line by line? Right now

  • 0

Is it possible to retrieve a txt files content line by line?

Right now I’m using this code:

var file = "http://plapla.com/pla.txt";
function getFile(){
     $.get(file,function(txt){
        save(txt.responseText);
 }); 
}

the save function saves the content into a variable.
And after I print it out all the content of the retrived file is in the end of each other(not line by line).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:02:22+00:00Added an answer on May 23, 2026 at 1:02 pm

    I’m not sure if you mean that when you print out the file that it gets all pushed onto one line, or if you are saying that you want to divide the file by line.

    If the problem is that when you display it, it gets pushed together, that is just because you are putting it into an HTML page, which means that newlines are ignored. You have two options then, either replace all of the newlines with <br /> tags, or put all of your text in a pre tag.

    var file = "http://plapla.com/pla.txt";
    function getFile(){
        $.get(file,function(txt){
            save(txt.responseText.replace(/\n/g, "<br />");
        }); 
    }
    
    // OR
    
    var file = "http://plapla.com/pla.txt";
    function getFile(){
        $.get(file,function(txt){
            save($("<pre />").text(txt.responseText));
        }); 
    }
    

    If you just want to work with the data line by line, then once you have received it, you can do whatever you like with it, just as splitting in up by line.

    var file = "http://plapla.com/pla.txt";
    function getFile(){
        $.get(file,function(txt){
            var lines = txt.responseText.split("\n");
            for (var i = 0, len = lines.length; i < len; i++) {
                save(lines[i]);
            }
        }); 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is this possible to retrieve Facebook user name and password in ios Application using
Is it possible to retrieve an external file (database) via link or form (
is it possible to retrieve by using connection.getschema() the description item from a sql
Hi (sorry for my ugly english) I wonder if this is possible to retrieve
I am trying to retrieve particular data from a txt file and would like
Is it possible to retrieve the information from a sent Push Notification using the
Is it possible to retrieve a file's name in C? If a file is
Is it possible to retrieve an array of request parameters with same key using
Is it possible to retrieve flashvar parameter in mxml code and if so how?
Possible Duplicate: Retrieve Windows Experience Rating Using .NET, is there a way to programmatically

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.