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,365 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Read about why website design really matters in today's demanding market.
I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

930 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now