<form class="form-inline" id="messageForm">
<input id="nameInput" type="hidden" class="input-medium" value="<?php echo $log_username;?>" />
<input id="canalInput" type="hidden" class="input-medium" value="<?php echo $name;?>" />
<input id="messageInput" name="messageInput1" placeHolder="Ваше сообщение"/>
<input type="submit" value="Отправить" onclick="$('.emoji-wysiwyg-editor').html('')"/>
</form>
var socket = io.connect( 'http://localhost:8080' );
$( "#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 } )
// Ajax call for saving datas
$.ajax({
url: "./ajax/insertNewMessage.php?1",
type: "POST",
data: { name: nameVal, message: msg, canal: canalVal },
success: function(data) {
}
});
return false;
});
};
var socket = io.connect( 'http://localhost:8080' );
$( "#messageForm" ).submit( function() {
var nameVal = $( "#nameInput" ).val();
var msg = $( "#messageInput" ).val();
var canalVal = $( "#canalInput" ).val();
if(msg) {
socket.emit( 'message', { name: nameVal, message: msg, canal: canalVal } )
};
// Ajax call for saving datas
$.ajax({
url: "./ajax/insertNewMessage.php?1",
type: "POST",
data: { name: nameVal, message: msg, canal: canalVal },
success: function(data) {
}
});
return false;
});
<script>
flag = true;
$( "#messageForm" ).submit( function() { var rewrew = $('#messageInput').html()
if(!flag) return false;
flag = false;
window.setTimeout(function () {
flag = true
}, 3000) ;
alert(rewrew);
return false;
});
</script>