Page 1 of 1

can someone write me simple js

Posted: Mon Feb 28, 2005 3:50 pm
by Lixas
I need that script read external file in write its content to variable. Maybe someone will be able to help me. I have tried do it by myself, but i have failed :(

Posted: Wed Mar 30, 2005 7:21 pm
by medwebinc
I dont believe there is a way to write that in javascript (If I am wrong please correct me) but there are other ways for example with activeX or Java applets.

Posted: Thu Mar 31, 2005 6:02 pm
by Lixas
ok, so if i'm not able to read external file in the same server so i will use php for reading and "echo" to javascript variable :D
PHP RULEZZ

Posted: Fri Feb 24, 2006 9:06 am
by kaos_frack
just enter src attribute in your script tag
like this:
<script type="text/css" language="javascript" src="./myScript.js"></script>

Posted: Thu Aug 10, 2006 5:03 am
by leegao
hey, there is a way to read a file on the server using the xmlHttpRequest object, its usage is this

Code: Select all

var xhr
if (ActiveXObject("Msxml2.XMLHTTP"))
{
xhr = new ActiveXObject("Msxml2.XMLHTTP")
}
else if (ActiveXObject("Microsoft.XMLHTTP"))
{
xhr = new ActiveXObject("Microsoft.XMLHTTP"))
}
else {
xhr = new XMLHttpRequest()
}

 xhr.open("GET", "filename.txt",true); 
 xhr.onreadystatechange=function() {
  if (xhr.readyState==4) {
   ****.getElementById("divChange").firstChild.value = (xhr.responseText)
  }
 }
 xhr.send(null)