Click to See Complete Forum and Search --> : Is there a way to read plain text on server ?


Jackyquah
February 27th, 2006, 03:38 AM
Is there a way to read plain text on server and store it on string variable ?

mmetzger
February 27th, 2006, 08:04 AM
Meaning read a text file in a seperate request and then use it? Yes - look at AJAX (you may want to visit the AJAX forum though it's still pretty new...)

Jackyquah
February 27th, 2006, 01:02 PM
Isn't AJAX is only read/write xml file with javascript ?

I want just plain text to be read

PeejAvery
February 27th, 2006, 02:24 PM
I want just plain text to be read
Then you will have to use a server-side language such as PHP or ASP.

Jackyquah
February 27th, 2006, 02:56 PM
I wouldn't ask in Javascript Forum. if I want to used other languages.

The Idea is the plain text contain part of html code like
<table>
...
</table>

so when using javascript I can insert to the current HTML page
Logical code :
var String=GetPlainTextString(UrlFilename)
[element].innerHTML=String

I don't want to used IFrame cause I must specify width and height and still it's using scroll bar if the content is larger.

I want it's fully show( as large as the content ) without using scrollbar.

Dr. Script
February 27th, 2006, 03:00 PM
Cool down.
You cannot read a file with just JavaScript. You'd have to use other technologies (AJAX) or other languages (PHP, ASP, etc). Both solution have been presented. To which forum would you like me to move this thread?

Jackyquah
February 27th, 2006, 03:31 PM
The reason I don't want used AJAX is because it's open in XML.

It will be pain to write in XML since HTML code is similiar to XML
i must using &lt &gt for < > and etc...
<xmldoccontent>
<table>
...
</table>
</xmldoccontent>

mmetzger
February 27th, 2006, 06:47 PM
Google is your friend...

http://ajaxpatterns.org/Plain-Text_Message

olivthill
March 1st, 2006, 04:09 PM
Maybe the following trick will be good enough for you:
<html>
<head>
<script src="html_inc.js" type=text/javascript></script>
</head>
<body>
<h1>Test</h1>
<script language=javascript>
document.write(more_html)
</script>
</body>
</html>with html_inc.js containing:
var more_html = "<table>"
more_html += "<tr>"
more_html += "<td>foo</td><td>bar</td>"
more_html += "</tr>"
more_html += "</table>"