It's a commonly asked question (see numbered links at end), but I can't work out how to solve it.
I include my javascript code below. I'm using MAMP PRO, and in the htdocs folder I've added a file '.htaccess' with contents 'Header set Access-Control-Allow-Origin "http://localhost:8888"' and reset the MAMP server but I get the same error.
Can someone suggest where I might be going wrong? Let me know if you need more info, I'm very new to this..
function loadComments(callback){
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();// code for IE7+, Firefox, Chrome, Opera, Safari
} else {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");// code for IE6, IE5
}
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
if (JSON.parse(this.responseText)[0]==null) {
} else {
alert(JSON.parse(this.responseText));
}
}
};
xmlhttp.open("GET","http://localhost:8888/projectX/projectX.php?webpageURL=" + "https://theguardian.com/au" ,false);
xmlhttp.send();
}
- The 'Access-Control-Allow-Origin' header has a value that is not equal to the supplied origin error
- The 'Access-Control-Allow-Origin' header has a value 'https://dev.getevents.co' that is not equal to the supplied origin
- The 'Access-Control-Allow-Origin' header has a value that is not equal to the supplied origin
- The 'Access-Control-Allow-Origin' header has a value 'http://localhost:4200' that is not equal to the supplied origin