I’m attempting to write a basic html page to control hardware on the BeagleBone Black. The HTML file looks like this:
`
`
And the .js file looks like this:
`
var app = require(‘http’).createServer(handler);
var io = require(‘socket.io’).listen(app);
var fs = require(‘fs’);
var bb = require(‘bonescript’);
app.listen(8090);
console.log(‘Server running on: http://’ + bb.getPlatform().ipAddress + ‘:8090’);
bb.pinMode(‘USR3’, ‘out’);
bb.digitalWrite(‘USR3’, 0);
function handler (req, res) {
fs.readFile(‘index.html’,
function (err, data) {
if (err) {
res.writeHead(500);
return res.end(‘Error loading index.html’);
}
res.writeHead(200);
res.end(data);
});
}
io.sockets.on(‘connection’, function (socket) {
socket.on(‘led’, function (data) {
console.log(data);
if (data == ‘on’) {
bb.digitalWrite(‘USR3’, 1);
socket.emit(‘ledstatus’, ‘green’);
socket.broadcast.emit(‘ledupdate’, ‘green’);
}
else {
bb.digitalWrite(‘USR3’, 0);
socket.emit(‘ledstatus’, ‘red’);
socket.broadcast.emit(‘ledupdate’, ‘red’);
}
});
});
`
And it works just fine. The problem is that my application will not have internet access which makes this line problematic:
`
`
So I downloaded jquery-2.1.1.min.js to the same directory as the HTML and .js files, and changed the above line to:
`
`
And it stops working, and I get the following errors when I use Chrome’s inspect element tool:
`
Uncaught SyntaxError: Unexpected token <
Uncaught ReferenceError: $ is not defined
`
Anybody know what’s going on here?