Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 7425
  • Last Modified:

Using JQuery to display text from a text file including the paragraph spacing found within the text file

OKay please only respond if you actually have an answer to this that you have tested please.  

So im using JQUery to access the contents of a text file found on my server.

I then tell Jquery to assign that text to a class which i've named "articletwo"

Upon executing that command the text displays in the div where i want it except that JQuery has ommited all the formating found with in the text (i.e spaces in between paragraphs, indents at the start of the paragraphs)

how can Jquery read the information found in this text file while still mainting the formating found within the text file?

####### this is in my header which calls up jquery and tells it to grab the text file##
 
<script type="text/javascript" src="http://www.djmichaelray.com/dreamchasers/articles/top_three_articles/jquery-1.2.6.js"></script>
<script type="text/javascript">
$(document).ready(function() {
        $.get("/dreamchasers/headline2.txt", function(data){
                $('.headlinetwo').text(data);
        });
});
$(document).ready(function() {
        $.get("full_article_two.txt", function(data){
        $('.articletwo').innerHTML(data.replace('\n','<br>'));
		});
});
</script>
 
 
##### this is how i call up the script in a class   ##########
 <div class="articletwo"></div>
          </div>

Open in new window

0
djmichaelray
Asked:
djmichaelray
  • 2
1 Solution
 
hieloCommented:
try this:
<script type="text/javascript" src="http://www.djmichaelray.com/dreamchasers/articles/top_three_articles/jquery-1.2.6.js"></script>
<script type="text/javascript">
$(document).ready(function() {
        $.get("http://www.djmichaelray.com/dreamchasers/headline2.txt", function(data){
                $('.headlinetwo').text(data);
        });
});
$(document).ready(function() {
        $.get("http://www.djmichaelray.com/dreamchasers/articles/top_three_articles/full_article_two.txt", function(data){
        $('.articletwo').html(data.replace('\n','<br>'));
            });
});
</script>
 
 
##### this is how i call up the script in a class   ##########
 <div class="articletwo"></div>
<div class="headlinetwo"></div>

Open in new window

0
 
djmichaelrayAuthor Commented:
Now absolutely no text shows up
0
 
hieloCommented:
In what I posted I am using the complete url to your files - http://...
in what you posted, you are not doing so. If you are testing on different server, then you will need to use the relative path, just like the ones you posted.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now