【发布时间】:2015-02-22 17:39:51
【问题描述】:
我想在我的节点 js 聊天应用程序中加载本地 jquery 文件。我已经搜索了很多,但我找不到合适的解决方案。
<!doctype html>
<html>
<head>
<title>Socketio</title>
</head>
<body>
<!--This wont work -->
<script src="/socket.io/jquery.min.js"></script>
<!--This will work -->
<script src="/socket.io/socket.io.js"></script>
</body>
</html>
我只是将 jquery.js 文件复制到 socket.io 文件夹。socket.io.js 文件正确加载但 jquery 文件没有。请帮助我
这是我的 index.js 文件
var app = require('express')();
var server = require('http').Server(app);
var io = require('socket.io')(server);
app.get('/', function(req, res){
res.sendFile(__dirname + '/index.html');
});
server.listen(3000, function(){
console.log('listening on *:3000');
});
【问题讨论】:
-
服务器端需要 jQuery 做什么?也许你想在 index.html 上加载它?
-
是的,我想在客户端加载文件
-
而不是像通常在 index.html 上那样放置它
-
但它没有工作。我会得到错误 cannot GET jquery file
标签: javascript jquery node.js socket.io