Contact form and ajax

I created a contact form that uses ajax to connect to my script on the server. When the response comes from the script, I can’t get the code to manipulate the response.
Any help will be greatly appreciated.

view site

.on("success.form.fv", function(e) {
      // Prevent form submission
      e.preventDefault();

      let $form = $(e.target),
        fv = $form.data("formValidation");

      // Use Ajax to submit form data
      $.ajax({
        url: $form.attr("action"),
        type: "POST",
        data: $form.serialize(),
        success: function(result) {
          // ... Process the result ...
          if (result === "success") {
            formSuccess();
          } else {
            submitMSG(false, result);
          }
        }
      });

const formSuccess = () => {
    $("#contactform")[0].reset();
    submitMSG(true, "Thanks! Your Message Has Been Sent.");
  };

  const submitMSG = (valid, msg) => {
    if (valid) {
      var msgClasses = "alert alert-success text-center";
    } else {
      $("#contactform")[0].reset();
      var msgClasses = "alert alert-danger text-center";
    }
    $("#formMessage")
      .removeClass()
      .addClass(msgClasses)
      .text(msg);
  };

the formSuccess() function does not run when I get a response of ‘success’.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.