I am trying to a simple HTML page working the text file is in the same directory but it does not want to work (ie unresponsive button). I did look at numerous examples but none of them shed light to the issue. The text file is in the same directory, I have tried absolute and relative paths. Is it possible that due to my orignation and request location being the same AJAX would shut down.
<!DOCTYPE html>
<html>
<head>
<script>
function loadXMLDoc()
{
// code for IE7+, Firefox, Chrome, Opera, Safari
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","\test.txt",true);
xmlhttp.send();
document.getElementById("myDiv").innerHTML=xmlhttp.responseText
}
</script>
</head>
<body>
<div id="myDiv"><h2>By the power of AJAX!!!!!!!</h2></div>
<button type="button" onclick="loadXMLDoc()">Change Content</button>
</body>
</html>
UPDATE corrected error on the cut and paste. By not working I mean the button does nothing. I have looked at other examples and none of them seem to work. When I try and run from my drive but work from the webpage. I do not have a server but I am only using text so I should not need anything beyond this.