<!DOCTYPE html>
<html lang="en-US">
<body>
<h1>JavaScript post Request</h1>
<p>Click on the button to send a post request.</p>
<button onclick="myFunction()">Click Me</button>
<script>
function myFunction() {
var data = JSON.stringify({ myname: "Alex" });
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
alert(this.responseText);
}
};
xhttp.open("POST", "/greet-specific.php", true);
xhttp.setRequestHeader("Content-type", "application/json");
xhttp.send(data);
}
</script> </body>
</html>