I have:
Index.php
<?php
if(isset($_POST["id"])){
echo($_POST["id"]);
}
?>
JavaScript:
let xhttp = new XMLHttpRequest();
xhttp.open("POST", "index.php", true);
xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded')
xhttp.onreadystatechange = function (){
if(xhttp.readyState == 4 && xhttp.status == 200)
{
let result = xhttp.responseText;
console.log(result)
}
}
xhttp.send("id=195");
But the console prints the whole HTML code for the php page. I thought it should print just the ID.