<!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 PHP</h1>
<p id="point"></p>
<button onclick="myFunction()">Receive from Server</button>
<script>
var x = document.getElementById("point");
var data = {};
function myFunction(){
$.post("/json-receive.php",{
// send no data
},function(serverData){
data = JSON.parse(serverData)
x.innerHTML = data[0].name;
});
}
</script>
<p><strong>Note</strong>: You will learn how to send and receive data in our <a href="/ajax" target="_parent">AJAX</a> tutorial. In this example, you will receive '[{ "name": "Mike", "age": 36}]' from the server.</p> </body>
</html>