Answer the question
In order to leave comments, you need to log in
Code instead of Node JS text?
There is a code for the client and the server, the application itself is like a chat, and so, if you send a message, then one code comes instead of text, what's the problem? client
var socket = io();
chat = document.querySelector("#chat");
function sendMsg() {
var msg = document.querySelector("#message").value;
socket.emit('sendMessage', msg);
socket.on('backMsg', function(data){
chat.append('<div class="well">'+data+'</div>');
data('');
});
}
socket.on('sendMessage', function(data){
io.sockets.emit('backMsg', data);
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question