json_decode('{"key":""}',true,2) // => Array
json_decode('{"a":{}}',true,2) //=>NULL
$( "#messageForm" ).submit( function(e) { e.preventDefault();
var nameVal = $( "#nameInput" ).val();
var msg = $( "#messageInput" ).val();
var canalVal = $( "#canalInput" ).val();
if(msg) {
socket.emit( 'message', { name: nameVal, message: msg, canal: canalVal } )
$( "#messageInput" ).val('');
// Ajax call for saving datas
$.ajax({
url: "./ajax/insertNewMessage.php",
type: "POST",
data: { name: nameVal, message: msg, canal: canalVal },
success: function(data) {
}
});
};
});
$( "#messageForm" ).submit( function() {
на $( "#messageForm" ).submit( function(e) { e.preventDefault();