Mailchimp API获取错误,无法使用ajax成功

我有来自mailchimp API V2.0的getitng正确响应的问题。

当我尝试订阅新用户时

var arr = { apikey:"xxxx", id:"secretListId", email:{ email:"jd@example.com" }, double_optin:"false" } function jsonpCallback (){ alert("jsonpCallback"); }; $.ajax({ type: 'GET', url: 'https://us6.api.mailchimp.com/2.0/lists/subscribe.json', dataType: 'jsonp', jsonpCallback: 'jsonpCallback', data: arr, timeout: 4000, cache: false, async: false, success: function(data, textStatus, jqXHR) { alert('success: '+data); }, error: function(jqXHR, textStatus, errorThrown){ alert('error: '+JSON.stringify(jqXHR)); }, complete: function(jqXHR, textStatus){ alert('complete: '+JSON.stringify(jqXHR)); } }).success(function(rsp){ console.log('success: '+rsp); }).fail(function(xhr,error,thrownError){ console.log('fail status:[' + xhr.status + '] error:[' + thrownError + ']'); }).always(function(){ console.log('complete'); }); }); 

在检查员我得到错误500。

并在警报弹出窗口中

在这个弹出窗口中,shold是另一条消息(错误500)。

但是,当我通过浏览器链接时,我得到:

 { "status": "error", "code": 214, "name": "List_AlreadySubscribed", "error": "jd@example.com is already subscribed to list mpowroznik.com List. Click here to update your profile." 

}

当然,如果我添加新的电子邮件,我会收到弹出警报

为什么这是错误,而不是成功?

我只使用没有PHP或其他语言的jQuery。

函数jsonpCallback根本不执行。

我必须做什么,以获得正确的响应信息。

出于特定原因,此API不应由浏览器中的代码使用。

通过在浏览器中发出此请求,任何使用发出此请求的页面的人都可以使用您的api密钥并向api发出他们自己的请求,就像他们一样,从而允许任何人窃取所有的电子邮件地址被添加到您的列表中(甚至清空列表。)

您必须使用服务器端语言(如PHP)与此api进行交互。 否则会损害用户/客户的安全性。

 function jsonpCallback(data){ alert(JSON.stringify(data[1])); return data; } $.ajax({ type: 'POST', url: 'http://xxx.us6.list-manage.com/subscribe/post-json?u=copiedFromActionForm&id=idList&c=?', data: data, cache: false, dataType: 'jsonp', success: function(data, text, xhr){ alert(JSON.stringify(data.msg)); }, error: function (xhr, text, error) { console.log('error') console.log(JSON.stringify(xhr.msg)); } }); 

在警报弹出窗口中,您将收到消息。

解决方案的想法来自https://github.com/scdoshi/jquery-ajaxchimp