Input being automatically cleaned

0

I am creating a chat but the input where the message is written will self-clean before sending the message follows the code to give me a hand of what can be, if in case you need more details put the complete 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);

});

    
asked by anonymous 06.02.2016 / 17:18

1 answer

0

The problem was that I was putting the $ ('# message'). val (''); in the part where I made the refresh I changed to soon after I sent the post and it worked. NOTE: beginner things not jquery handle

$(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);
});
    
06.02.2016 / 17:37