asmerkin / slideform

A JQuery Sliders Form
https://asmerkin.github.io/slideform
21 stars 8 forks source link

Submitting form to Server & then Showing last slide for successful message #3

Open nerdyator opened 4 years ago

nerdyator commented 4 years ago

I was trying implement this with server-side form submission. Whenever I submit the form my page refreshes cause of default behaviour of browser. How to prevent that so that I can show last slide as successful submission of form.

Im using the same code snippet as mentioned in example demo. That is:

index.html

custom.js var $slideForm = $('#dataForm'); $('#dataForm').slideform({ submit: function(event, form) { $slideForm.submit(); //not sure whether I need this or not, if this is enable it goes into loop $slideForm.trigger('goForward'); } }); jquery.slideform.js $form.on('submit',function ( event ) { if ( $options.submit ) { event.preventDefault(); $options.submit (event, $form); } }); Thanks in advance
asmerkin commented 4 years ago

The form submission doesn't actually submit the form but triggers the submit option in your setup. From there you should execute an ajax call to your server with $.ajax to submit the form. After you get the response, you could trigger goForward to show the next slide, which is the success message.