"submitHandler Callback Default: default (native) form submit Callback for handling the actual submit when the form is valid. Gets the form as the only argmument. Replaces the default submit. The right place to submit a form via Ajax after it validated. Submits the form via Ajax when valid.
$(".selector").validate({ submitHandler: function(form) { $(form).ajaxSubmit(); } }) " But i just can't get it to work?? How do I AJAX-submit the form? How do I use $(form).ajaxSubmit(); ? On Feb 23, 3:02 pm, Andri <4r53...@gmail.com> wrote: > I think the problem is not on serialize, because the ajax submit is > working when using this function > > $("#RegForm").submit(function(){ > var str = $(this).serialize(); > > $.ajax({ > type: 'POST', > url: 'ajax.php', > data: str, > success: function(msg) { > if(msg == 'OK') { > $('#status').html('<b>Data Has Been > Added to Database</b>'); > } else { > $('#status').html(msg); > } > } > }) > $('form :input').val(""); > $('form :input[type=submit]').val("Submit"); > > return false; > }); > > but when i combine it with validation it doesnt work > > On Feb 23, 5:13 pm, tain <bugi....@gmail.com> wrote: > > > i forgot to add link for more details about serialize() > > >http://docs.jquery.com/Ajax/serialize > > > On Feb 23, 11:12 am, tain <bugi....@gmail.com> wrote: > > > > this is what i found on jquery.documentation, > > > > "Serialize requires that fields have a name attribute. Having only an > > > id will not work." > > > > On Feb 23, 8:10 am, Andri <4r53...@gmail.com> wrote: > > > > > I have a form, and i want to combing jquery validation ajax Submit and > > > > jquploader. > > > > > This is the script > > > > > $("#RegForm").validate({ > > > > submitHandler: function(form) { > > > > jQuery(form).ajaxSubmit({ > > > > var str = $("#RegForm").serialize(); > > > > > $.ajax({ > > > > type: 'POST', > > > > url: 'ajax.php', > > > > data: str, > > > > success: > > > > function(msg) { > > > > if(msg > > > > == 'OK') { > > > > > > > > $('#status').html('<b>Data Has Been Added to Database</b>'); > > > > } else { > > > > > > > > $('#status').html(msg); > > > > } > > > > } > > > > }) > > > > $('form > > > > :input').val(""); > > > > $('form > > > > :input[type=submit]').val("Submit"); > > > > > return false; > > > > }); > > > > } > > > > }); > > > > > But it got an error on => var str = $("#RegForm").serialize();\n > > > > (missing : after property id) > > > > > How to solve this ?