I have made an app with nodejs and with socket.io which echos messages to and fro from the client to the server... Here's a tiny bit of my server code:
io.on('connection', function(socket){
socket.on('sentmsg', function(msg){
io.emit('sentmsg', msg);
});
});
And here's my code on the client side :
var socket = io();
$('form').submit(function(){
socket.emit('sentmsg', $('#m').val());
$('#m').val('');
return false;
});
socket.on('sentmsg', function(data){
$('#boxf').append($('<li>').text(data));
alert(data);
});
It should append to the element in my html code but it is changing into a url followed by a query string like ?msg="the msg I entered"
Please help
Thanks in advance
Aucun commentaire:
Enregistrer un commentaire