Javascript Ajax()不工作不确定脚本是否正确加载
我正在尝试使用API通过MailChimp发送电子邮件。通过这样做,我可以避免使用任何类型的后端。我不知道我的Jquery脚本文件是否设置错误Javascript Ajax()不工作不确定脚本是否正确加载,javascript,jquery,ajax,Javascript,Jquery,Ajax,我正在尝试使用API通过MailChimp发送电子邮件。通过这样做,我可以避免使用任何类型的后端。我不知道我的Jquery脚本文件是否设置错误 $(document.ready(function () { $('#survey').click(function() { $.ajax({ type: “POST”, url: “https://mandrillapp.com/api/1.0/messages/send.json”, dat
$(document.ready(function () {
$('#survey').click(function() {
$.ajax({
type: “POST”,
url: “https://mandrillapp.com/api/1.0/messages/send.json”,
data: {
‘key’: ‘api Key’,
‘message’: {
‘from_email’: ‘email’,
‘to’: [
{
‘email’: ‘email’,
‘name’: ‘RECIPIENT NAME (OPTIONAL)’,
‘type’: ‘to’
}
],
‘autotext’: ‘true’,
‘subject’: ‘Class Survey’,
‘html’: ‘Here is your survey link: <a>link</a>’
}
}
}).done(function(response) {
console.log(response);
});
});
});
谢谢你的帮助 这是因为你使用了错误的双引号 使用此
“
代替此”
使用此'
而不是'
$(文档).ready(函数(){
$(“#调查”)。单击(函数(){
$.ajax({
类型:“POST”,
url:“https://mandrillapp.com/api/1.0/messages/send.json",
数据:{
“键”:“api键”,
“消息”:{
“来自电子邮件”:“电子邮件”,
“致”:[
{
“电子邮件”:“电子邮件”,
“名称”:“收件人名称(可选)”,
'type':'to'
}
],
“自动图文集”:“真”,
“主题”:“班级调查”,
“html”:“这是您的调查链接:link”
}
}
}).完成(功能(响应){
控制台日志(响应);
});
});
});
我还想提一下,在我自己的脚本文件之前,我在脚本中包括了jQuery。$(document.ready
=>$(document.ready
Uncaught SyntaxError: Invalid or unexpected token
$(document).ready(function() {
$('#survey').click(function() {
$.ajax({
type: "POST",
url: "https://mandrillapp.com/api/1.0/messages/send.json",
data: {
'key': 'api Key',
'message': {
'from_email': 'email',
'to': [
{
'email': 'email',
'name': 'RECIPIENT NAME (OPTIONAL)',
'type': 'to'
}
],
'autotext': 'true',
'subject': 'Class Survey',
'html': 'Here is your survey link: <a>link</a>'
}
}
}).done(function(response) {
console.log(response);
});
});
});