我已经按照 这篇文章 的指引,使用 Mandrill 发送邮件的 JavaScript 代码,但是在控制台中出现了以下错误:
“我做错了什么?”
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://mandrillapp.com/api/1.0/messages/send.json. This can be fixed by moving the resource to the same domain or enabling CORS.
以下是我的代码:$('#submitEmail').click(function() {
$.ajax({
type: "POST",
url: "https://mandrillapp.com/api/1.0/messages/send.json",
data: {
'key': 'my_api_key',
'message': {
'from_email': 'test@hotmail.com',
'to': [{
'email': 'test@gmail.com',
'name': 'RECIPIENT NAME (OPTIONAL)',
'type': 'to'
}],
'autotext': 'true',
'subject': 'test',
'html': 'test'
}
}
}).done(function(response) {
console.log(response);
});
});
“我做错了什么?”