Quantcast
Channel: User Michael Paulukonis - Stack Overflow
Viewing all articles
Browse latest Browse all 44

Answer by Michael Paulukonis for Moving javascript file to external reference in Node.JS called HTML

$
0
0

Move the code that is currently inside of your script tag to a separate file, say side.js:

  $(document).ready(function() {    $('#mainTable').DataTable( {"ajax": "jsonData","columns": [            { "data": "level" },            { "data": "value" },            { "data": "description" }        ]    } );  } );

Change the script tag to be

<script source="./side.js"></script>

It looks from some of your other code (require...) that you are attempting to execute Node.js inside of the HTML. Node.js is executed on the server side; all of the Javascript in the HTML will be executed on the client-side (browser).


ETA: now that you've updated with the code, I see that, yes, you are attempting to use Node.js inside of the HTML. It won't work - you can't require inside of the user's browser.


Viewing all articles
Browse latest Browse all 44

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>