我想测试PHP阿贾克斯用一个简单的program.I我使用HTML和PHP文件都存储在同一目录(/ var/www/html等) 。当我点击按钮,它显示了在控制台下面的错误。 XML解析错误:没有根元素中找到位置。 ??XML解析错误:没有根元素中找到位置(PHP +阿贾克斯)
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";
?>
什么是错的代码?