$("form").submit(function() { var th = $(this); $.ajax({ type: "POST", url: "mail.php", data: th.serialize() }).done(function() { alert("Thank you!"); setTimeout(function() { th.trigger("reset"); }, 1000); }); return false; }); 

There is a script to send the form, tell me how, instead of an alert, display the hidden div with thanks?

    1 answer 1

    Add a div tag to the page

     <div id="hiddiv">Thank you!</div> 

    Add script

     $("form").submit(function() { var th = $(this); $.ajax({ type: "POST", url: "mail.php", data: th.serialize() }).done(function() { $('#hiddiv').show(); setTimeout(function() { th.trigger("reset"); }, 1000); }); return false; }); 

    Add to css

     #hiddiv { display: none; }