私は簡単なプログラムでphp-Ajaxをテストしたいです.htmlとphpファイルを使用していますが、両方とも同じディレクトリ(/ var/www/html) 。ボタンをクリックすると、コンソールに次のエラーが表示されます。 XML解析エラー:ルート要素が見つかりません。 ??XML構文解析エラー:ルート要素が見つかりません位置(php + Ajax)
htmlファイル
<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ファイルは
<?php
echo "Hello";
?>
このコードで何が間違っているのですか?