0
Well, I am trying to perform a simple ajax request, but the called content is not being displayed. How can I resolve ?
var xmlhttp;
function callContent(){
var mainContent = document.querySelector(".main-content");
xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", "random.php", true);
xmlhttp.onreadystatechange = callback(mainContent);
xmlhttp.send();
}
function callback(contentDiv){
console.log(xmlhttp);
if(xmlhttp.readystate == 4 && xmlhttp.status == 200){
contentDiv.innerHTML = xmlhttp.responseText;
}
}
This.log console is showing the content correctly?
– Marlysson
not either, but when I open Random.php it works perfectly. readystatechange status is 0, even if you ask for open and send
– Murilo Melo