curl --request POST \
--url 'https://usX.api.mailchimp.com/3.0/lists/1234/members' \
--user 'username:api_key' \
--header 'content-type: application/json' \
--data '{"email_address":"user@example.com", "status":"pending"}' \
--include
I've above curl and it's working fine when I try to add subscriber to my Mailchimp list.
However, I'm not sure how to convert this curl to working jQuery AJAX POST request since I only know how to pass data
to AJAX POST.
Since this curl has --user
, --header
and --include
, I don't know how to build the correct AJAX.
Please help.
$.ajax({
url : "https://usX.api.mailchimp.com/3.0/lists/1234/members",
type: "POST",
data: {email_address: "user@example.com", status: "pending"},
// stuck here - what else should I put?
});