I want to test php-Ajax with a simple program.I am using html and php file both are stored in same directory (/var/www/html). when I click on button it shows following error in console. XML Parsing Error: no root element found Location. ??
html file
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<title> Ajax testing </title>
<script type="text/javascript">
function load(){
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("result").innerHTML = this.responseText;
}
};
xmlhttp.open("GET", "simple.php" , true);
xmlhttp.send();
}
</script>
</head>
<body>
<button onclick="load();">Click here</button>
<div id="result"> </div>
</body>
</html>
php file
<?php
echo "Hello";
?>
what is wrong with this code ?