This site is mobile accessible. Press the "Tap Here" button to use a different font-size.


Smartphone icons created by Freepik - Flaticon

Get JSON Data from a PHP Server

// create XMLHttpRequest function
const xmlhttp = new XMLHttpRequest();

// create myObj JS array and display myObj.name
xmlhttp.onload = function() {
  const myObj = JSON.parse(this.responseText);
  document.getElementById("demo").innerHTML = myObj.name;
}

// define XMLHttpRequest object
xmlhttp.open("GET", "demo_file.php");
xmlhttp.send();

demo_file.php