不知道为什么我得到了一个未捕获的语法错误:意外结束的输入错误,老实说,我已经使用了这个片段在许多地方之前,从来没有这个问题?我显然只是代码盲今天下午!
<!-- 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条答案
按热度按时间v64noz0r1#
底部缺少' }); '。只需将其添加到/script标记的正上方。您需要关闭$(document).ready(function(){