I need a data to be updated in ajax but depending on the selected date, for example, if the date is less than today it should show a div showing something, and if it exceeds today's date it should show another div, currently only handle basic ajax, I attach the basic example (the official example) of ajax that is what is used, can someone help me with this?
function loadDoc() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("demo").innerHTML = this.responseText;
}
};
xhttp.open("GET", "ajax_info.txt", true);
xhttp.send();
}
<!DOCTYPE html>
<html>
<body>
<div id="demo">
<h2>Let AJAX change this text</h2>
<button type="button" onclick="loadDoc()">Change Content</button>
</div>
</body>
</html>