1

I am writing a website that, in part, parses JSON from the web so I can use the data. I am able to get it to work some of the time, however when I parse certain URLs I get this error:

Failed to load resource: https://data-live.flightradar24.com/clickhandler/?version=1.5&flight=220a5af7 Origin null is not allowed by Access-Control-Allow-Origin.

The method I am using to parse the JSON data is working as I am able to parse another URL. However, when I try and look at this URL it won't let me.

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" >
    <title>Cool Plane Finder, its cool</title>
</head>
<body>

<script>

var URLTwo = "https://data-live.flightradar24.com/clickhandler/?version=1.5&flight=220a5af7";
console.log(URLTwo);

var requestTwo = new XMLHttpRequest();
requestTwo.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
        var clickHandler = JSON.parse(this.responseText);
        for(var value in clickHandler) {
            var test = (clickHandler[value][0]);
            console.log(test);
        }

    }
}
requestTwo.open("GET", URLTwo, true);
requestTwo.send();  

</script>
</body>

<html>

If my code was to work, the intended outcome would be for me to be able to see what is within the JSON document and use it within more code.

Nick Parsons
  • 45,728
  • 6
  • 46
  • 64
Logan
  • 11
  • 1

0 Answers0