私は ajax を使用して div を介して echo にあるものを表示したいだけの非常に小さなコードを作成しましたが、 echo にあるものではなく php スクリプト全体を表示します。誰かが私を助けてくれますか?
<html>
<script type="text/javascript" >
function test() {
xmlHttp=new XMLHttpRequest();
if (xmlHttp !== null) {
xmlHttp.onreadystatechange=function() {
if(xmlHttp.readyState==4 && xmlHttp.status==200) {
var response = xmlHttp.responseText;
alert("Match");
alert(response);
document.getElementById('show').innerHTML = response;
}
}
}
xmlHttp.open("GET","try.php",true);
xmlHttp.send(null);
}
</script>
<body>
Enter answer: <input type="text" onKeyUp="test();"><br />
See returned value: <div id="show"></div>
</body>
</html>
これは私のphpファイルです。エコーにあるものを出力するかどうかを確認したかったので、小さいです
<?php
echo "i just want to see if this get's printed";
?>