私はapp.jsにこのコードを持っています
var app = require('http').createServer(handler),
io = require('socket.io').listen(app),
static = require('node-static');
var fileServer = new static.Server('./');
app.listen(8080);
function handler (request, response) {
request.addListener('end', function () {
fileServer.serve(request, response);
});
}
io.set('log level', 1);
io.sockets.on('connection', function (socket) {
socket.on('click', function () {
socket.broadcast.emit('moving');
});
});
Index.html
<script>
var url = window.location.hostname;
var socket = io.connect(url);
socket.on('moving', function () {
$("body").append('<div class="text">tex</div>');
});
</script>
簡単なテキスト(div)を書きたいのですが、うまくいきません。どこで問題が発生する可能性がありますか?