I've tried to modify this post but for some reason it's not working, I'm quite new to JS so I could be missing something in the code I just can't tell where.
I'm building a 3 stage process out of tabs, the tabs are:
- contact form;
- tab 2;
- tab 3;
I don't want the user to have to click 'Submit' on the form and then a separate 'Continue' button to go to the second tab, so I'm looking to apply a Javascript query/callback to the form submission button that links to the second tab but only if the form has been submitted successfully.
This is my existing Javascript:
<script>
jQuery(document).ready(function() {
jQuery(".dhvc-form-submit").submit(function() {
jQuery.ajax({
type: "POST",
url: "form_handler.php",
data: jQuery(this).serialize(),
success: function() {
window.location = '#an_76234532'; });
}
})
})
})
</script>
Currently this isn't triggering anything.
The submit button's class is .dhvc-form-submit
,
The second tab has the href ID #an_76234532
.
Have I missed something and if not how can I achieve this functionality?