Well, I'm 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;
}
}