Code has been added to clipboard!

Getting PHP File With AJAX

Example
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function(){    
if (this.readyState == 4 && this.status == 200) {  
   var newObj = JSON.parse(this.responseText);
   document.getElementById("JSON").innerHTML = newObj.fruit;
}};
xmlhttp.open("GET", "demo.php", true);
xmlhttp.send();