I need to get content from another page inside the site using Javascript, I tried to use ajax, however it gives this error "Cross-origin request blocked: Same Origin Policy prevents reading of the remote resource in < (Reason: CORS 'Access-Control-Allow-Origin' header is not present). "
I need to get the value of some divs and put in variables, I need to do this using JavaScript.
How to do this?
Used code:
function showUser(str) {
if (str == "") {
document.getElementById("cabecalho").innerHTML = "";
return;
} else {
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("cabecalho").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("GET","https://www.google.com.br");
xmlhttp.send();
}
}
showUser("str");