Hi, I’m running into a similar issue with the Webflow/Mailchimp integration.
Minimal sample site is here, set up per the Webflow University episode: https://form-test-94b795.webflow.io/
If I post to Mailchimp using Postman with the data that Webflow generates, I get a (sort of) valid response:
?({"result":"success","msg":"Almost finished... We need to confirm your email address. To complete the subscription process, please click the link in the email we just sent you."})
Note that this is jsonp including the ‘?’ that was provided as the callback function name - I’m unclear why exactly Webflow is using ‘?’ for this, or how it plans to parse ?()
.
When Webflow receives this response in submitMailChimp(data)
however it results in a jQuery ajax parsererror, as jQuery expected an ‘anonymous’ function as the callback which is then never called:
fail parsererror Error: jQuery331005864688326717293_1555015853676 was not called
I’m having difficulties crafting the correct jQuery ajax call to succeed with Mailchimp here. I suspect it has to do with this: javascript - Make cross-domain ajax JSONP request with jQuery - Stack Overflow, where Mailchimp expects a callback name provided in c=
, but jQuery automagically jams it into context=
. Not sure how to reconcile this, and if this is indeed the case, how this integration ever worked (which I assume it did/does). Per this answer, the c=?
is part of the magic.
Certainly from a debugging perspective it would be nice if the fail handler in the following code was a little more verbose so we could determine if these things are an issue with Webflow or Mailchimp.
url: url,
data: payload,
dataType: 'jsonp'
}).done(function (resp) {
data.success = resp.result === 'success' || /already/.test(resp.msg);
if (!data.success) {
console.info('MailChimp error: ' + resp.msg);
}
afterSubmit(data);
}).fail(function ( /* why no use of jqXHR, textStatus, errorThrown? */ ) {
afterSubmit(data);
});
And as a general comment, I wish all of these email campaign tools would just let us set up a proper CORS header to allow us to leave this easily exploitable jsonp nastiness in the past where it belongs. The awful state of this mess is somewhat summed up in this Webflow source comment: // Use the (undocumented) MailChimp jsonp api
.
Thanks for considering!