Thanks to help on StackOverflow I was able to validate and submit two forms to different action pages. I need to have the success functions change depending on which form was submitted.
This is my javascript:
$("form").each(function() {
$(this).validate({
submitHandler: function(form) {
var $form=$(this)
var data= $form.serialize()
$.ajax({
type : 'POST',
url : $(form).attr('action'),
data : $(form).serialize(),
cache : false,
dataType: 'text',
success: function(data){
},
});
return false; // Temporary
}
});
This is success for form 1:
$("#e1").prepend(data);
var magnificPopup = $.magnificPopup.instance;
magnificPopup.close();
This is success for form 2:
$("#messageTran").html(data);
$("#messageTran").hide();
$("#messageTran").fadeIn(1500);
What is the best way for me to achieve this? I am very new to javascript and haven't been able to find an answer for this. I have tried passing a form attribute with an if else statement, but have had no luck. Thank you in advance.