vendredi 15 juillet 2016

how to clear form after successful submit ajax


I would like to make the contact form disappear after successful submission but am not sure how to go about it. Any assistance would be appreciated.

jQuery(document).ready(function($) {
$("#ajax-contact-form").submit(function() {

        var str = $(this).serialize();

        $.ajax({
            type: "POST",
            url: "contactfinal.php",
            data: str,
            beforeSend: function() {
                $("#submit").hide();
                 $("#loading").show();
                  },
            success: function(response) {
               $('#error').html(response);
                $("#submit").show();
                $("#loading").hide();

            }
        });
        return false;
    });
});

Aucun commentaire:

Enregistrer un commentaire