i have made a very small code in which i just want to show what's in echo through div with ajax but it shows me the whole php script instead of what's in echo , can someone help me
<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>
this is my php file , i just wanted to check if it prints what's in echo so it's small
<?php
echo "i just want to see if this get's printed";
?>
Check the Network tab in your browser's development console. In Chrome, press F12, go to the "Network" tab, execute your test()
function, and check the appropriate response in the Network results. You can see the result in the "Response" tab. Similar consoles should exist for other browsers.