function subscribe(to_send, url) {
$.ajax({
url: url,
data: to_send,
dataType: 'jsonp',
success: function(data) { console.log('Response', data) },
error: function (data) { console.log('FUUUUU: ' + data) }
})
}
to_send = http://evaline.us14.list-manage.com/subscribe/post-json?u=76ee17f86cd92d4984c0046f8&id=15deb1bbee&c=?
和to_send = JSON.stringify(data)
,其中数据如下:
data = {
"email_address": inputs[1].value,
"email_type": "html",
"status": "subscribed",
"status_if_new": "subscribed",
"merge_fields": {
"FNAME": inputs[0].value
},
"interests": {
"9b4ccc9f43": isInvestor,
"82636e7cd9": isEmployee,
"c8b187e22d": isBusiness,
"798cc04c42": isUser,
"d750ac8858": isOther,
}
}
input [i]正确评估字符串,isSomeRole计算为布尔值。我用console.log确认他们确实正确地评估了这样的事情:
"{\"email_address\":\"a@a.io\",\"email_type\":\"html\",\"status\":\"subscribed\",\"status_if_new\":\"subscribed\",\"merge_fields\":{\"FNAME\":\"a\"},\"interests\":{\"9b4ccc9f43\":false,\"82636e7cd9\":false,\"c8b187e22d\":false,\"798cc04c42\":true,\"d750ac8858\":false}}"
...这是正确的字符串化数据。
当我执行subscribe()时,它似乎正确提交,运行success:function(data)位,响应如下:
Response – {result: "error", msg: "Blank email address"}
这是我执行subscribe('', url)
时得到的完全相同的反应 - 似乎data
根本没有附加/发送......
我真的很困惑。我应该不字符串化data
吗?我应该用那个有效载荷做些什么吗?我在ajax声明中遗漏了什么吗?