Be a Supporter!

Load .txt into website

  • 268 Views
  • 2 Replies
New Topic Respond to this Topic
Blounty
Blounty
  • Member since: Nov. 16, 2008
  • Offline.
Forum Stats
Member
Level 13
Movie Buff
Load .txt into website 2012-05-17 04:40:20 Reply

Need some help on why my code isn't working.

HTML

<div id="content">

<?PHP
include "content.txt" ;
?>

</div>

CSS

#content {
	width: 50%;
	height: 100%;
	position: absolute;
	left: 25%;
	top: 400px;
	z-index: 5;
}

Sig created by HighWay

BBS Signature
centerfuge
centerfuge
  • Member since: Sep. 2, 2008
  • Offline.
Forum Stats
Member
Level 02
Programmer
Response to Load .txt into website 2012-05-17 09:16:11 Reply

At 5/17/12 04:40 AM, Blounty wrote: Need some help on why my code isn't working.

HTML

<div id="content">

<?PHP
include "content.txt" ;
?>

</div>

CSS

#content {
width: 50%;
height: 100%;
position: absolute;
left: 25%;
top: 400px;
z-index: 5;
}

Try AJAXing it into the page. Get jQuery and link it in the page's head tag. using

<script src="jquery.js" type="text/javascript" />

Next, do a

<script type="text/javascript">$.ajax({url: 'content.txt',complete: function(jqXHR,textStatus) {$('#content').html(jqXHR.responseText);}});</script>

jQuery can be downloaded from jquery.com

VigilanteNighthawk
VigilanteNighthawk
  • Member since: Feb. 13, 2003
  • Offline.
Forum Stats
Member
Level 03
Blank Slate
Response to Load .txt into website 2012-05-19 13:13:15 Reply

No need for ajax for this. You can just read the file like and output it like this:

<?php
echo file_get_contents('content.txt');
?>

The Internet is like a screwdriver. You can use it to take an engine apart and understand it, or you can see how far you can stick it in your ear until you hit resistance.