Click to See Complete Forum and Search --> : J.S.-Getting Data From External File
burozoption
04-16-2004, 09:39 AM
Is it possible to get data from an external source like a text file using javascript?
What I am looking to do is to pull data from a text from and put it into a textarea box.
crh3675
04-16-2004, 09:44 AM
<html>
<script type="Text/javascript">var xmlhttp
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try {
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
} catch (e) {
try {
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
} catch (E) {
xmlhttp=false
}
}
@else
xmlhttp=false
@end @*/
if (!xmlhttp) {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp=false
}
}
function loadXML(url){
xmlhttp.open("GET", url,true);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {
document.forms[0].theText.value=xmlhttp.responseText
}
}
xmlhttp.send(null)
}
</script>
<body onload="loadXML('http://www.google.com')">
<form>
<textarea id="theText" cols="55" rows="15"></textarea>
</form>
</body>
</html>