有没有一种方法不使人们重定向到“谢谢"的位置? Mailchimp的页面? [英] Is there a way not to redirect people to a "thank you" page with Mailchimp?
问题描述
我在Mailchimp网站上看到,当他们订阅您的邮件列表时,您可以将用户重定向到自定义的感谢页面,但这并不是我想要的.
I saw on the Mailchimp website that you can redirect the user to a custom thank you page when they subscribe to your mailing list, but that's not exactly what I want to do.
当用户订阅我的邮件列表时,我想隐藏该表单并直接用我的页面上的感谢信替换它,而无需任何重定向.有办法吗?
When a user subscribe to my mailing list, I want to hide the form and replace it with a thank you note directly on my page without any redirection. Is there a way to do that?
推荐答案
您可以通过修改表单操作来做到这一点.
You can do this by modifying the form action.
将"subscribe/post"更改为"subscribe/post-json" ...
Change "subscribe/post" to "subscribe/post-json" …
<form action="...list-manage.com/subscribe/post-json?u=...."
在表单中添加一个提交处理程序:
Add a submit handler to the form:
$("#subscribe-form").submit(function(e){
e.preventDefault();
submitSubscribeForm($("#subscribe-form"));
});
通过AJAX提交表单(从Github此处引用的代码 ):
Submit the form via AJAX (Code referenced from Github here):
function submitSubscribeForm($form, $resultElement) {
$.ajax({
type: "GET",
url: $form.attr("action"),
data: $form.serialize(),
cache: false,
dataType: "jsonp",
jsonp: "c",
contentType: "application/json; charset=utf-8",
error: function(error){},
success: function(data){
if (data.result != "success") {
var message = data.msg || "Sorry. Unable to subscribe. Please try again later.";
if (data.msg && data.msg.indexOf("already subscribed") >= 0) {
message = "You're already subscribed. Thank you.";
}
$resultElement.html(message);
} else {
然后编写代码以显示注册确认
And then write the code to display the signup confirmation
$resultElement.html("Thank you!<br>You must confirm the subscription in your inbox.");
}
}
});
}
这篇关于有没有一种方法不使人们重定向到“谢谢"的位置? Mailchimp的页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!