chasemb
chasemb

Reputation: 167

Uncaught SyntaxError: Unexpected token } debugging in Chrome

I can't figure out what is going on. I'm using Chrome to debug my js. It says unexpected } but it clearly needs it. If I delete the }, I get "Uncaught SyntaxError: Unexpected end of input".

Any help appreciated.

$(document).ready(function() {
            $("#payment-form").submit(function(event) {
                if (!$("input[name=agree]").is(":checked")) {
                        return false;
                    } else {
                        $('.submit-button').attr("disabled", "disabled");
                        // createToken returns immediately - the supplied callback submits the form if there are no errors
                        Stripe.createToken({
                          number: $('.card-number').val(),
                          cvc: $('.card-cvc').val(),
                          exp_month: $('.card-expiry-month').val(),
                          exp_year: $('.card-expiry-year').val()
                        }, stripeResponseHandler);
                        return false;
                        }
                    }
                }

            if (window.location.protocol === 'file:') {
                alert("stripe.js does not work when included in pages served over file:// URLs. Try serving this page over a webserver. Contact [email protected] if you need assistance.");
            }

Upvotes: 2

Views: 3911

Answers (2)

nathanjosiah
nathanjosiah

Reputation: 4459

you have mismatching and missing curly braces try this:

$(document).ready(function() {
    $("#payment-form").submit(function(event) {
        if (!$("input[name=agree]").is(":checked")) {
            return false;
        } else {
            $('.submit-button').attr("disabled", "disabled");
            // createToken returns immediately - the supplied callback submits the form if there are no errors
            Stripe.createToken({
                number: $('.card-number').val(),
                cvc: $('.card-cvc').val(),
                exp_month: $('.card-expiry-month').val(),
                exp_year: $('.card-expiry-year').val()
            }, stripeResponseHandler);
                return false;
        }
    });

    if (window.location.protocol === 'file:') {
        alert("stripe.js does not work when included in pages served over file:// URLs. Try serving this page over a webserver. Contact [email protected] if you need assistance.");
    }
});

Upvotes: 4

epascarello
epascarello

Reputation: 207501

Well the code above is missing a } and ) at the end.

Upvotes: 0

Related Questions