can someone write me simple js
can someone write me simple js
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
-
- Posts: 504
- Joined: Sat May 07, 2005 8:03 am
- Contact:
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)