我想发送填写联系表单的所有输入数据。
javascript中的联系表单
function sendMail() {
$.ajax({
type: 'POST',
url: 'https://mandrillapp.com/api/1.0/messages/send.json',
data: {
'key': 'YOUR API KEY HERE',
'message': {
'from_email': 'YOUR@EMAIL.HERE',
'to': [
{
'email': 'RECIPIENT@EMAIL.HERE',
'name': 'RECIPIENT NAME (OPTIONAL)',
'type': 'to'
}
],
'autotext': 'true',
'subject': 'YOUR SUBJECT HERE!',
'html': 'YOUR EMAIL CONTENT HERE! YOU CAN USE HTML!'
}
}
}).done(function(response) {
console.log(response); // if you're into that sorta thing
});
}
答案 0 :(得分:0)
将key/value
对替换为textboxes
的值,如下所示
{
...
'subject': $('#txtSubject').val(),
...
}
此处,txtSubject
是主题id
的{{1}}。像这样,您可以替换要发送给API的所有字段。
答案 1 :(得分:0)
阅读完查询后,我会找到一个解决方案
$.ajax({
url: 'https://mandrillapp.com/api/1.0/messages/send.json',
type: 'POST',
data: {
'key': <your_key>,
'form-data': form.serialize()
}
})
您将获得form-data
词典中值的所有输入名称的关键字。