<!DOCTYPE html>
<html lang="en-US">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
</head>
<body>
<h1>JSON.stringify()</h1>
<p id="point"></p>
<button onclick="myFunction()">Send to Server</button>
<script>
var x = document.getElementById("point");
var data = { name: "Mike", age: 36};
function myFunction(){
$.post("/json-name.php",{
myData: JSON.stringify(data)
},function(serverData){
x.innerHTML = serverData;
});
}
</script>
<p><strong>Note</strong>: You will learn how to send and receive data in our <a href="/ajax" target="_parent">AJAX</a> tutorial. By the way, try to remove JSON.stringify() and send the data to the server.</p> </body>
</html>