Submitting form via Ajax and handling response

Posted 2 years ago

        $.ajax({
            type: "POST",
            url: url, 
            data: form.serialize(), 
            success: function(data) {

              if(data == 'Success'){
                $("p#response").text('Success, your message has been sent');
                $("p#response").addClass( "contact-success" );                   
              } else {
                $("p#response").text(data);
              }
              //console.log(data);

            }
          });