我不明白发生了什么事。我正在使用 Chrome 来调试我的 js。它说意外}但它显然需要它。如果删除 },我会收到“Uncaught SyntaxError: Unexpected end of input”。
任何帮助表示赞赏。
$(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 <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="72010702021d0006320106001b02175c111d1f" rel="noreferrer noopener nofollow">[email protected]</a> if you need assistance.");
}
最佳答案
你有不匹配和缺少的大括号,试试这个:
$(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 <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d0a3a5a0a0bfa2a490a3a4a2b9a0b5feb3bfbd" rel="noreferrer noopener nofollow">[email protected]</a> if you need assistance.");
}
});
关于javascript - 未捕获的语法错误 : Unexpected token } debugging in Chrome,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9900095/