jQuery Form go through e.preventDefault() to CodeIgniter controller if successful post - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: jQuery Form go through e.preventDefault() to CodeIgniter controller if successful post (/showthread.php?tid=57128) |
jQuery Form go through e.preventDefault() to CodeIgniter controller if successful post - El Forum - 02-18-2013 [eluser]thekalaban[/eluser] Overview I have a form: Code: <?php echo form_open_multipart( 'new_account/validate_new_account', array('id' => 'main-form') ); ?> I submit it to my controller's validate_new_account() function: Code: function validate_new_account() I use the jQuery Form Plugin to interact with the controller. Code: var options = { Problem Without my ajax function, the code above works perfectly but I have dynamically added elements which requires ajax to handle all validations or else these elements will be gone (bad UX). So if I enable and use my ajax function, the validation errors from CodeIgniter are printed out how I want BUT if all validations are now correct, the form does not go to $this->view_preview_form( $this->get_post_data() );. Why is this happening? I've search for similar problems but sadly none helped my weird case. How can I get pass through e.preventDefault() if the form was sent successfully? jQuery Form go through e.preventDefault() to CodeIgniter controller if successful post - El Forum - 02-18-2013 [eluser]Otemu[/eluser] Hi Use this Code: if (data.length === 0) { jQuery Form go through e.preventDefault() to CodeIgniter controller if successful post - El Forum - 02-18-2013 [eluser]thekalaban[/eluser] Thank you sir! jQuery Form go through e.preventDefault() to CodeIgniter controller if successful post - El Forum - 02-18-2013 [eluser]thekalaban[/eluser] Hello, someone already in SO got the solution. Thanks. Solution |