请原谅我的第一篇文章!我能够使用
成功发送“硬编码”global_merge_vars `"autotext": "true",
"merge": "true",
"global_merge_vars": [
{
"vars":
{
"name": "LSMESSAGE",
"content": "hardcoded"
}
}
],
"subject": "*|LSMESSAGE|*",
"html": "<p> *|LSMESSAGE|* </p>"`
但无法将名为 clsm 的变量传递给“内容”。
"autotext": "true",
"merge": "true",
"global_merge_vars": [
{
"vars":
{
"name": "LSMESSAGE",
"content": ctlsm
}
}
],
"subject": "*|LSMESSAGE|*",
"html": "<p> *|LSMESSAGE|* </p>"
我刚刚在邮件中得到了星号*|LSMESSAGE|*星号。 第一个问题-这里可以使用变量吗? (我确实尝试将 ctlsm 放在引号中:“ctlsm”) 如果是,我做错了什么?该变量是在 mandrill post 之前声明的,并且有一个值,但似乎在 $ajax 部分中失去了它的值。
// send email using mandrill and API key
$.ajax({
type: "POST",
url: "https://mandrillapp.com/api/1.0/messages/send.json",
data: { etc etc
最佳答案
在 JavaScript 中添加 + 号来连接字符串
"content": "+ctlsm+"
这里是变量与字符串的连接示例。
var text = "hello"
document.write(text+" world"); /// this will write hello world
关于javascript - mandrill合并标签不接受变量值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29444057/