-2

Hi following is my full HTML and Javascript code, but while running in browser shows error Uncaught ReferenceError: draw is not defined test.html:13.

<html>
    <head>
        <title>Testing D3</title>
        <script type="text/javascript" src="d3-v5.js"/>
        <script type="text/javascript">
            function draw(data){
                console.log(data);
            }
        </script>
    </head>
    <body>
        <script type="text/javascript">
            draw(12);
        </script>
    </body>
</html>
Vatsal Jagani
  • 83
  • 1
  • 8

1 Answers1

0

You can't use self-closing tag apparently, change the d3 import to this:

  <script type="text/javascript" src="d3-v5.js"></script>

<html>
    <head>
        <title>Testing D3</title>
        <script type="text/javascript" src="d3-v5.js"></script>
        <script type="text/javascript">
            function draw(data){
                console.log(data);
            }
        </script>
    </head>
    <body>
        <script type="text/javascript">
            draw(12);
        </script>
    </body>
</html>
Tom G
  • 3,650
  • 1
  • 20
  • 19