-1

I am making a website template and I though of a cool new trick to save time when changing large text files. I want to have a separate plain text document that when the page loads, it contents will be transferred to my paragraph.

Example:

The text document:

Introducing the new red glasses.

The paragraph's text will be loaded and be the same as the text documents like so:

<p> Introducing the new red glasses. </p>

So how can I do something like this? Is it even possible? I am willing to use HTML, CSS, jQuery and Javascript.

Barmar
  • 741,623
  • 53
  • 500
  • 612
Lae
  • 832
  • 1
  • 13
  • 34
  • You could use Server-Side Include. – Barmar Jul 05 '14 at 14:48
  • You can use PHP to include the content within the page template. Javascript is not the way to go. You want to do this on the server side. Maybe you need a content managment system like WordPress. – Marc Audet Jul 05 '14 at 15:15

1 Answers1

0

You could use AJAX:

$.get( "mytext.txt", function( txt ) {
    $( "#myParagraph" ).text( txt );
});

You will need to host your HTML from a server, or otherwise it won't work

Dirk
  • 2,094
  • 3
  • 25
  • 28