Answer the question
In order to leave comments, you need to log in
How to clear data in nodeJS?
Hello. Here is a script for transmitting data over a socket.
var socket = io.connect( 'http://localhost:8080' );
$( "#messageForm" ).submit( function() {
var nameVal = $( "#nameInput" ).val();
var msg = $( "#messageInput" ).val();
var canalVal = $( "#canalInput" ).val();
if((nameVal) && (msg)){
socket.emit( 'message', { name: nameVal, message: msg, canal: canalVal } )};
// Ajax call for saving datas
$.ajax({
url: "./ajax/insertNewMessage.php",
type: "POST",
data: { name: nameVal, message: msg, canal: canalVal },
success: function(data) {
}
});
return false;
});
socket.on( 'message', function( data ) {
var actualContent = $( "#messages" ).html();
var newMsgContent = '<li> <strong>' + data.name + '</strong> : ' + data.message
.replace(new RegExp("&#D83DDE04",'gi'),"<img src='../packs/basic/D83DDE04.png' height='20' width='20'>")
.replace(new RegExp("&#D83DDC8A",'gi'),"<img src='../packs/basic/D83DDC8A.png' height='20' width='20'>") + '</li>';
var content = newMsgContent + actualContent;
$( "#messages" ).html( content );
});
$( "#messages" ).html( content );
stores data that will be replaced on the next request. If I understood correctly, then how do I clean it up? Or explain, please, what's what. Thanks
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