I am serving up some html using nodeJS, but I want to be able to call functions that are in a javascript file, which I am trying to link. However, I am getting the error message Resource interpreted as Script but transferred with MIME type text/html: "http://localhost:8888/index.js". I'm not sure what that won't link properly, and need a way to link my file index.js. What I was trying to do was load the file into the head, as follows:
http = require('http'),
http.createServer(function(req, res) {
var body = '<html>'+
'<head>'+
'<script src="index.js"></script>'+
'<meta http-equiv="Content-Type" content="text/html; '+
'charset=UTF-8" />'+
'</head>'+
'<body>'+
'</body>'+
'</html>';
response.writeHead(200,{"Content-Type":"text/html"});
response.write(body);
response.end();
}
}).listen(8888);
How can I load this javascript file, index.js, so that all of the functions contained in index.js will be available on the client side?