its my code:
<script>
function testingAPI(){
theUrl = "https://api.github.com/users/juliolimacostavalladares";
var xmlHttp = new XMLHttpRequest();
xmlHttp.onload = function() {
alert(xmlHttp.responseText);
};
xmlHttp.onerror = function() {
alert(xmlHttp.status);
};
xmlHttp.open( "GET", theUrl, false);
xmlHttp.setRequestHeader("Accept","application/json");
xmlHttp.setRequestHeader("Access-Control-Allow-Origin","*");
xmlHttp.send(null);
}
</script>
<body>
<button onclick="testingAPI()"> send request </button>
</body>
and when i run it i got CORS error. what can i do to resolve the problem? thank you.
when i try the url in a browser it works. but in javascript it raises a CORS error.