JavaScript (Ajax) add new contact - possible?

SOLVED
Go to solution
DaveM654
Occasional Participant

JavaScript (Ajax) add new contact - possible?

The scenario:

 

- We have an existing form that is submitted to another 3rd-party service via their API

- We want to add a "Subscribe to newsletter" checkbox. If checked, the email address only will be sent to a Constant Contact List

 

To do these both with one form, I will need to make an Ajax request to the first service, and in the success handler, fire off the relevant data to the other service.

 

In the old days-- impossible. Cross-origin policy would block the script from executing. But now that a service can return a response with CORS headers set, it should be not only possible, but easy!

 

Problem: the other 3rd-party service does NOT currently set the necessary headers.

 

Question: does Constant Contact's API have a way to close the Ajax loop and trigger the success handler? It doesn't matter at all which order things go in; I'm happy to send to CC first and then the other service on success.

1 ACCEPTED SOLUTION
Mark-C
Member

Hello,

 

We have not implemented the cross-origin resource sharing (CORS), and are not likely to do so in the foreseeable future, so your best option is still to use a server-side solution.

 

Cheers,

Mark Coleman
Support Engineer

View solution in original post

2 REPLIES 2
Mark-C
Member

Hello,

 

We have not implemented the cross-origin resource sharing (CORS), and are not likely to do so in the foreseeable future, so your best option is still to use a server-side solution.

 

Cheers,

Mark Coleman
Support Engineer

View solution in original post

DaveM654
Occasional Participant

Thanks, Mark. Not the answer I hoped for obviously (nor when Salesforce gave it to me!) but an answer nonetheless that lets me move forward with what I need to do.

 

Thanks again

 

Developer Portal

View API documentation, code samples, get your API key.

Visit Page