How to fix a JavaScript error

0

I'm using the javascript library p5.js , and I'm trying to access local files , in the current case I'm trying to load a json file through the loadJSON (url) function provided by the library. But I'm having some errors in this attempt. I have already checked the formatting of the json file and it is correct.
Obs : In Mozilla Firefox browser is working correctly, but in Google Chrome and Opera are generating the same errors as shown in the image:

var jsonn1;
function preload(){
  jsonn1 = loadJSON("json1.json");
}

function setup() {
  testeJSON();
}

function draw() {
}

function testeJSON(){
  document.getElementById('teste').innerHTML = jsonn1[0].titulo;
  document.getElementById('teste').setAttribute('href', jsonn1[1].link);
}
<!DOCTYPE html>

<html>
  <head>
    <title>json test</title>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-viewport, initial-scale=1" />

    <!--CDN Files-->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.6.1/addons/p5.dom.js"></script><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.6.1/p5.js"></script>

    <!--Local Files-->
    <script language="javascript" type="text/javascript" src="sketch.js"></script>
    <script type="text/javascript" src="json1.json"></script>

  </head>

  <body>

    <div id="teste" href="">
    </div>

  </body>

</html>

    
asked by anonymous 05.05.2018 / 02:10

0 answers