成功完成表单后,我无法将用户重定向到“谢谢”页面.发生的情况是,在提交表单后,它会转到空白页(https://cunet.sparkroom.com/Sparkroom/postLead)…我需要它重定向到“感谢”页面,同时将表单详细信息提交到“表单操作”中的URL.
<form action="https://cunet.sparkroom.com/Sparkroom/postLead/" method="post" name="theForm"
id="theForm" onSubmit="return MM_validateForm();" >
...
</form>
Ajax代码:
<script src="http://malsup.github.com/jquery.form.js"></script>
<script>
$('#theForm').ajaxForm(function() {
window.location.href = "I want the user to be redirected to this page";
});
</script>
JavaScript的:
function MM_validateForm() {
if ( !jQuery('#theForm #FirstName').val() ) {
alert('Please input your first name.');
jQuery('#theForm #FirstName').focus();
return false;
}
if ( !jQuery('#theForm #LastName').val() ) {
alert('Please input your last name.');
jQuery('#theForm #LastName').focus();
return false;
}
if ( !jQuery('#theForm #daytimephone').val() ) {
alert('Please input your phone number.');
jQuery('#theForm #daytimephone').focus();
return false;
}
if ( !jQuery('#theForm #Email').val() ) {
alert('Please input your email.');
jQuery('#theForm #Email').focus();
return false;
}
if ( !jQuery('#theForm #BID').val() ) {
alert('Please select your preferred campus.');
jQuery('#theForm #BID').focus();
return false;
}
if ( !jQuery('#theForm #programs').val() ) {
alert('Please select your preferred program.');
jQuery('#theForm #programs').focus();
return false;
}
if ( !jQuery('#theForm #How_Heard').val() ) {
alert('Please select how you heard about us.');
jQuery('#theForm #How_Heard').focus();
return false;
}
return true;
}
// ]]></script>
有人知道我在做什么错吗?我需要将表单提交到URL的表单,然后将用户重定向到“谢谢”页面之后,这根本没有发生.
解决方法:
尝试
window.location.href = "http://www.msdn.com";