I'm trying to send a XMLHttpRequest from a html file to a php file. Both are in the same folder and I have XAMPP Apache active and running(if I run the php file by itself, it works as expected). Problem is, the response from the php file is its own text, instead of what it echoed. The XMLHttpRequest is successful, in the sense that it has a status of 200
Code from the html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ajax 4-Ajax and PHP form</title>
</head>
<body>
<button id="button">Get Name</button>
<script>
document.getElementById("button").addEventListener("click",getName);
function getName()
{
var xhr=new XMLHttpRequest();
xhr.open("GET","process.php",true);
xhr.onload=function(){
console.log("status: "+this.status);
console.log(this.responseText);
}
xhr.send();
}
</script>
</body>
</html>
Code from my process.php file:
<?php
echo "Processing...";
?>
The output I expect when I click the button is for the console to log 200 Processing... but it logs 200 plus the inside of the php file