【发布时间】:2017-12-12 08:47:31
【问题描述】:
我可以看到代码中没有错误,但它仍然显示这个 语法错误:缺失;声明前 screenshot
这是表格:
<form id="bildo_mc_form" action="https://stylishcreativity.us3.list-manage.com/subscribe/post-json?u=7c7040d58ca368b8f8063c1ea&id=f67dfc67a4" method="post">
<input id="mc-email" type="email" name="EMAIL" placeholder="Your Email">
<label for="mc-email"></label>
<button type="submit">Send</button>
</form>
这里是 Js:
jQuery("#bildo_mc_form").submit(function(e){
console.log("form submitted");
function callbackFunction(data){
window.location.href = "http://thanks.com";
console.log("sucess result" + data.result);
console.log("sucess msg" + data.msg);
}
var url = jQuery(this).prop('action'); // the script where you handle the form input.
jQuery.ajax({
type: "GET",
url: url,
data: jQuery("#bildo_mc_form").serialize(), // serializes the form's elements.
dataType: "jsonp",
contentType: "application/json; charset=utf-8",
error: function(error){
// According to jquery docs, this is never called for cross-domain JSONP requests
console.log("Error Result" + error.result);
},
success: callbackFunction
});
e.preventDefault(); // avoid to execute the actual submit of the form.
});
我怎样才能摆脱这个问题? 请帮助:)
【问题讨论】:
-
我已经在 jshint 中验证了你的代码,那里没有问题。你检查过this similar question吗?这可能是同一个问题。
-
我已经尝试了他们在类似问题上提到的所有可能的修复,但仍然无法正常工作!对于 MailChimp 表单,您必须将 dataType 设置为 JSONP,否则表单将不会提交 prntscr.com/ftf6gj
标签: javascript jquery html ajax mailchimp