Input cleaning itself automatically

Asked

Viewed 21 times

0

I am creating a chat but the input where the message is written autoclean before sending the message follows the code to give me a hand of what can be, if you need more details put the full code

script

   $(function() {
afficheConversation();
$('#envoyer').click(function() {
    var nom = $('#nom').val();
    var message = $('#message').val();
    $.post('chat.php', {'nom':nom, 'message': message }, function() {
      afficheConversation;
    });
});

function afficheConversation() {
  $('#conversation').load('chatlog.htm');
  $('#message').val('');
  $('#message').focus();
}
setInterval(afficheConversation, 3000);

});

1 answer

0

solved the problem was that I was putting the $('#message'). val(''); in the part where I was doing the refresh I changed it to right after I sent the post and it worked. NOTE: things of beginners not jquery manjo

$(function() {
afficheConversation();
$('#envoyer').click(function() {
    var nom = $('#nom').val();
    var message = $('#message').val();
    $.post('chat.php', {'nom':nom, 'message': message }, function() {
      afficheConversation;
    $('#message').val('');
    });
});

function afficheConversation() {
  $('#conversation').load('chatlog.htm');
  $('#message').focus();
}
setInterval(afficheConversation, 3000);
});

Browser other questions tagged

You are not signed in. Login or sign up in order to post.