Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
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
Medium Priority
?
7,411 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1500 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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …

730 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