Im testing out the Parsley framework and i must say I really do like how simple it is to implement.
My only issue, is that if i try to attach an ajax submit if the form is validated correctly, it just doesnt seem to catch on.
below is my code.
<form data-validate="parsley" action="reply.html" method="post" id="main-form">
<input type="text" name="email" data-type="email" data-required="true" /><br />
<input type="submit" name="submit" />
</form>
<script>
$("#main-form").submit(function(event){
event.preventDefault();
$.ajax({
type: "post",
url: $(this).attr('action'),
data: $("#main-form").serialize(), // serializes the form's elements.
dataType : 'json',
success: function(data)
{
if(data[0].status == 'success')
{
alert('its working ok');
}
}
});
});
/* end simple ajax form post */
</script>
all it seems to do, is allow me to validate the form, then post it normally, however im looking for an easy way to simply validate the form and if all is good, submit the data via ajax.
I cant seem to find an easy way of doing this via their help docs... any advice greatly appreciated