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,359 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
Comment Utility
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
Comment Utility
Now absolutely no text shows up
0
 
LVL 82

Accepted Solution

by:
hielo earned 500 total points
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

771 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

10 Experts available now in Live!

Get 1:1 Help Now