i have this simple HTML which calls a JS function:
<body>
<h1 onclick="scrape()"> Scrape! </h1>
...
<script src="main.js"></script>
</body>
And this JS script (main.js):
function scrape() {
var xhttp = new XMLHttpRequest();
xhttp.open("GET", "https://www.wikipedia.org/", true)
xhttp.send();
}
When I run the scrape() function it returns an error because of the Same Origin Policy.
After reading an SO post about this problem I'm quite confused...
I read of "Access-Control-Allow-Origin: *" and this should make my site access to other sites' data, but I can't understand how to use it, could you please help me and tell me the way to make my function work?