Local copy of jquery is not working

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?

Having this same problem now. Did you ever figure this out?

Try using the devlopers version of JQuery. Sometimes the minified versions can cause unexpected problems.

If that does not solve your problem then I would have to read through your whole code base to see for myself what is going on - And I’m not exactly prepared to do that . . .

*Uncaught ReferenceError: $ is not defined*

Is related to the first error. Most probably because you’re using the JQuery ‘$’ symbol in your own code.

But the first error makes it sound as though you’re not using matching brackets properly. Which is kind of silly, since it’s an opening bracket. So, I’d check for typos in your files . . . on all the lines prior to the line where Chrome’s element inspector says it’s having an error.

Hi,

The problem you have here is that you are missing some dependencies.
When you access jquery online everything is fine.
When you access it from a local drive you actually need to clone the whole repo, not only jquery-*.min.js

Hope this will help.
Jan