[英]Mailchimp AJAX jQuery Unexpected token <
I wrote the following jQuery code (Ajax sending of mailchimp): 我写了以下jQuery代码(Ajax发送mailchimp):
function formAjaxSending() {
var form = $('.block_main-footer__form');
form.submit(function (e) {
e.preventDefault();
$.ajax({
url: 'http://linkedin.us13.list-manage.com/subscribe?u=xxxxxxxxxxxxxxxxxxxxx&id=xxxxxxxxxxxxxxxxxxxxxxxxx',
type: 'GET',
crossDomain: true,
data: form.serialize(),
dataType: 'jsonp',
contentType: "application/jsonp; charset=utf-8",
success: function (data) {
if (data['result'] != "success") {
alert('error');
}
else {
alert('success')
}
}
});
});
}
formAjaxSending();
But it produces the following error with the jQuery plugin AJAXChimp: 但它使用jQuery插件AJAXChimp产生以下错误:
Uncaught SyntaxError: Unexpected token <
With this error, I also see this link: 有了这个错误,我也看到了这个链接:
http://linkedin.us13.list-manage.com/subscribe?u=xxxxxxxxxxxx&id=xxxxxxxxx&callback=jQuery22407884056930053507_1469228177975&email=xxxxxxxxxxxxxxxx0gmail.com&_=1469228177976
I don't have any server-side code, so I can't elaborate more on that. 我没有任何服务器端代码,因此我无法详细说明。 Can anyone help me with solving this problem? 任何人都可以帮我解决这个问题吗?
Had the same problem just today. 刚才有同样的问题。
I couldn't find a solution so I changed approach. 我找不到解决方案所以我改变了方法。
Go to Mailchimp -> List -> Signup Forms 转到Mailchimp - >列表 - >注册表单
and create a Embedded Form. 并创建一个嵌入式表单。
Copy/Paste on your HTML (emit everything but the form content) 复制/粘贴HTML(发出除表单内容之外的所有内容)
Now download AjaxChimp and follow readme.md 现在下载AjaxChimp并关注readme.md
in your JS insert 在你的JS插入中
$('#mc-embedded-subscribe-form').ajaxChimp({
url: 'http://yourid.us12.list-manage.com/subscribe/post?u=90d7ecc6fadf95bf8c79xxxx&id=e2c1f57xxxx'
//callback: callbackFunction
});
You can find the url in form action="" 你可以在表格action =“”中找到网址
Works for me. 适合我。
If you're going to submit the form client-side, you'll need to alter the form action and method. 如果您要提交客户端表单,则需要更改表单操作和方法。
In the action, instead of "/post", you'll need to change it to "/post-json". 在动作中,而不是“/ post”,您需要将其更改为“/ post-json”。
Before: http://yourid.us12.list-manage.com/subscribe/post?xxx 之前:http: //yourid.us12.list-manage.com/subscribe/post?xxx
After: http://yourid.us12.list-manage.com/subscribe/post-json?xxx 之后:http: //yourid.us12.list-manage.com/subscribe/post-json?xxx
And also change the "post" method to "get". 并且还将“post”方法更改为“get”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.