You need to use AJAX for this. This is easy with jQuery.
const dUrl = "http://www.domain.com";
$.ajax(
{
url: dUrl,
success: function(result){
console.log(result);
}
}
);
You will need to add / import jQuery for it to work.
If you do not want to add ajax, then:
function loadData(url) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
console.log(xhttp.responseText);
}
};
xhttp.open("GET", url, true);
xhttp.send();
}
this AJAX