$('#submsgp').click(function(){
ping_waiting=1;
$.ajax({
type: 'POST',
data: 'op=svm&room_id=0&id_faq=&cplugin=&ss=hhsit&last_id='+$('#last_id').val()+'&ac=savm&type=chat&cont='+$('#msgchatter').val(),
url: 'http://localhost/test/hhsit?op=svm',
dataType: 'json',
crossDomain : true,
success : function (response) {
if (response.quest!='ok' && response.status!=undefined){
if (response.lastid!=undefined && response.status_text!='' && $('#last_id').val(response.lastid)!=response.lastid){
$('#chat_bodyCtr').append(response.status_text);
}
}
if (response.status_text!='' && response.status_text!=undefined){
if (response.lastid!=undefined && response.status_text!='' && $('#last_id').val(response.lastid)!=response.lastid){
$('.nofound_message').hide();
// chatter_play_s('incoming');
}
}
if (response.lastid!=undefined && response.status_text!='' && $('#last_id').val(response.lastid)!=response.lastid){
var d = $('.chat_bodyCtr');
d.animate({ scrollTop: d.prop('scrollHeight') }, 1000);
}
if (response.lastid!=undefined && response.lastid>0){
$('#last_id').val(response.lastid);
}
},
error:function(jXHR, textStatus, errorThrown) {
alert('Error while sending message: '+errorThrown+'...');
ping_waiting=0;
},
complete: function() {
$('#msgchatter').attr('value', '');
ping_waiting=0;
},
timeout: 5000,
cache: false
});
return false;
});
var d = $('#chat_bodyCtr');
d.animate({ scrollTop: d.prop('scrollHeight')+500 }, 1000);
setInterval('chatter_doAjaxPing()',timex_pingx);
})({});
Guys I am terrible with jQuery.
Could you please help me out to somehow prevent users from posting messages in less than 5 seconds apart.
And don’t post message that only contains spaces. Needs to contain at least 2 real letters or numbers.