Hi guys!
I have a form with a button and a textarea, when i click on the button it opens a text file and displays its content in the textarea
the problem is when i update the file and click the button the changes i made to the file don't show in the textarea, it only shows the old content.
here's my code
<script type="text/javascript">
var req;
var FileName="http://localhost/file.txt";
function OpenFile(url) {
req = false;
// branch for native XMLHttpRequest object
if(window.XMLHttpRequest && !(window.ActiveXObject)) {
try {
req = new XMLHttpRequest();
} catch(e) {
req = false;
}
// branch for IE/Windows ActiveX version
} else if(window.ActiveXObject) {
try {
req = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try {
req = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
req = false;
}
}
}
if(req) {
req.onreadystatechange = processReqChange;
req.open("GET", url, true);;
req.send("");
}
}
function processReqChange() {
// only if req shows "loaded"
if (req.readyState == 4) {
// only if "OK"
if (req.status == 200) {
document.getElementById('txtOutput').value=req.responseText;
} else {
alert("There was a problem retrieving the XML data:\n" + req.statusText);
}
}
}
</script>
<input type="button" id="btnOpen" value="Open File" onClick="OpenFile(FileName)" /><br />
<textarea id='txtOutput' rows='20' cols='100'></textarea>
//----------------------------------------------End code--------------------------------------------------------------------------
Can anybody tell me if anything wrong in my code
Thanks in advance