I was going through some examples of sending server side data to client side in Node js. But then I tried the following, it gave me Reference Error. I would like to know where am I making the mistake? Thanks.
server.js -
var express = require('express')
require('highcharts');
var app = express();
app.engine('html', require('ejs').renderFile);
dirname = "C:/Users/user/WebstormProjects/untitled/public";
require("jsdom").env("", function(err, window) {
if (err) {
console.error(err);
return;
}
var $ = require("jquery")(window);
});
app.listen(3000, function () {
console.log('Example app listening on port 3000!')
});
app.get('/', function (req, res) {
var data = 5;
res.render("data.html",{Data:data});
});
data.html -
<html>
<head>
<script src="http://code.jquery.com/jquery-1.11.3.min.js" ></script>
<script src="http://code.highcharts.com/highcharts.js" ></script>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
</head>
<body>
<div id="container" style="width:100%; height:400px;"></div>
<script type="text/javascript">
var d = JSON.stringify(Data);
console.log(d);
</script>
</body>
</html>