I\'m having problems redirecting the user to a thank you page after a successful form completion. What happens is that after the form submits, it goes to a blank page (https://c
There are two way to redirect user after successful form post.
1) You can put a on Success event in ajax submission in which you can simply redirect user to thankyou page.
2) Use a server side function after your form post processing done For Ex in PHP:
header("Location: http://thankyoupage.html");
Try:
$('#theForm').ajaxForm(function() {
success : function(){
window.location.href = "Url to redirect here in the success option";
}
});
Try
window.location.href = "http://www.msdn.com";
You could hadle the submit post with jquery, so you will have to cancel the action in the form
<form name="theForm" id="theForm" >
just give a class or ID to the submit button
<submit class='submitTheForm'....>
the code will be like this.. you just need to include all the form variables with the right name.
Then add the jquery post request at the bottom of MM_validateForm()
if ( !jQuery('#theForm #How_Heard').val() ) {
alert('Please select how you heard about us.');
jQuery('#theForm #How_Heard').focus();
return false;
}
$.post("https://cunet.sparkroom.com/Sparkroom/postLead/",
{
FirstName:FirstName,
LastName:LastName
...
...
},
function(){
window.location.href = 'thank you page'
}
});
And finally call the function MM_validateForm() when the submit button get clicked
$('.submitTheForm').click( function(){
MM_validateForm();
});
jquery post from http://api.jquery.com/jQuery.post/ the rest from personal experience.