0

Not sure why I'm getting an Uncaught SyntaxError: Unexpected end of input error on this, to be honest I have used this snippet in many places before and never had this issue? I obviously am just code blind this afternoon!

<!-- jquery and bootstrap -->
<script src="js/libs.min.js?t=1494075642"></script>
<script src="js/template.js?t=1494075642"></script>
<script>
    // =======================
    // SUBMIT TO MAILCHIMP
    // =======================
    $(document).ready( function () {
    var action = "https://<<client_name>>.us13.list-manage.com/subscribe/post-json?u=207e8e8eebc7ed702d92e7928";
    var form = $('.mailchimp');

    if ( form.length > 0 ) {
        $('.mailchimp button[type="submit"]').on('click', function(e) {
            e.preventDefault();
            form = $(this).closest(".mailchimp");
            register(form);
        });
    }

    function register(form) {
        $.ajax({
            type: form.attr('method'),
            url: form.attr('action'),
            data: form.serialize(),
            cache       : false,
            dataType    : 'json',
            contentType: "application/json; charset=utf-8",
            error       : function(err) {
                alert("Could not connect to the registration server. Please try again later.");
            },
            success     : function(data) {
                if (data.result != "success") {
                    $('#success').addClass("alert-danger").toggle().find("p").text(data.msg);
                    $('#mailchimpModal').modal('show');
                    $form.reset();
                } else {
                    $('#success').addClass("alert-success").toggle().find("p").text(data.msg);
                    $('#mailchimpModal').modal('show');
                    $form.reset();
                }
            }
        })
    }

</script>
1
  • Proper indentation will help to find the error Commented Nov 16, 2017 at 16:40

1 Answer 1

2

You are missing ' }); ' at the bottom. Just add it right above the /script tag. You need to close out your $(document).ready( function() {

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.