Looking to use vanilla JS for loading content dynamically without needing a page refresh. The goal is to retrieve content from another HTML file when a menu option is selected, while targeting either the body or a specific class.
Is it possible to achieve this without relying on jQuery?
Thank you in advance!
var AJAX = function(page){
var request = new XMLHttpRequest();
request.open("GET", page);
request.send();
request.addEventListener("load", function(response){
console.log(response.target.responseText); // Currently displaying all HTML as text, but desire to extract either the body or a particular class and utilize it within an innerHTML method.
});
}