0
<form id="myForm" name="gadaj"> <input type="text" name="fname" id="fname"/> 
<input type="submit" name="click" value="button"> </form> <p id="status"></p>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
      <script>
         function info()
         {
          document.getElementById("status").innerHTML="Message Sent";
     setTimeout(function() {
$('#status').fadeOut('slow');
   }, 1000);
         }
$(document).ready(function(){

     $(function(){
        $("#myForm").submit(function(event){
            event.preventDefault();
            $.ajax({
                method: 'POST',
                url: 'submit.php',
                data : $('#myForm').serialize(),

                   success: function (response){
  {
      document.forms['myForm'].reset();
      info();   
  }

                },
                     error: function(XMLHttpRequest, textStatus,errorThrown) {
 alert("Some Error.");
  }

            });

        });
    });
});

</script>
   <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
  </head>
  <body>
    <form id="myForm" name="gadaj">
    <input type="text" name="fname" id="fname"/>
    <input type="submit" name="click" value="button" id="klik">

</form>

 <p id="status"></p>
</body>
</html>

Now it's only one time shows Message Sent. It's kind of webchat txt field and I wanna show message text every time after sent. How do this ? I do not know Ajax. I just found it but I do not how to do any change.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
joe
  • 9
  • 3

0 Answers0