Is there a way not to redirect people to a “thank you” page with Mailchimp?

∥☆過路亽.° 提交于 2019-12-04 19:44:21

You can do this by modifying the form action.

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"));
});

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.");
                }
            }
        });
    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!