Solved

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

Posted on 2008-06-20
3
7,375 Views
Last Modified: 2012-05-05
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
Comment
Question by:djmichaelray
  • 2
3 Comments
 
LVL 82

Expert Comment

by:hielo
ID: 21834957
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
 

Author Comment

by:djmichaelray
ID: 21836269
Now absolutely no text shows up
0
 
LVL 82

Accepted Solution

by:
hielo earned 500 total points
ID: 21836328
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question