title: Mailchimp how to call mailchimp 3.0 API in javascript
body: <p>I am trying to subscribe an email to a list on mailchimp, I followed the documentation first, made a request using "Postman" added what was needed and everything works just fine, so I tried to do it on my website and it didn't work</p>
  
  <p>I tried to made a simple request with the same values I set on postman, but everytime I try to send the request the response says </p>
  
  <blockquote>
    <p>XMLHttpRequest cannot load
    <a href="https://us12.api.mailchimp.com/3.0/lists/xxxxxx/members" rel="noreferrer">https://us12.api.mailchimp.com/3.0/lists/xxxxxx/members</a>. Response
    to preflight request doesn't pass access control check: No
    'Access-Control-Allow-Origin' header is present on the requested
    resource. Origin '<a href="https://mywebsite.com" rel="noreferrer">https://mywebsite.com</a>' is therefore not allowed
    access. The response had HTTP status code 501.</p>
  </blockquote>
  
  <p>I tried to find a way to overcome this but it has been impossible</p>
  
  <p>I searched on stackoverflow everybody says to use jsonp or add something to the ajax call or use a mailchimp ajax plugin nothing has worked</p>
  
  <p>I tried diferent stackoverflow posts like this one
  <a href="https://stackoverflow.com/questions/21526408/mailchimp-subscribe-using-jquery-ajax">Mailchimp subscribe using jQuery AJAX?</a>
  but almost all of them say  the same</p>
  
  <p>I tried <code>cache: false</code> <code>dataType:jsonp</code> <code>crossDomain: true</code> <code>xhrFields: {withCredentials: true}</code></p>
  
  <p>Here it is my code, I am using Jquery</p>
  
  <pre><code>$.ajax({
            type: "POST",
            url: "https://usxx.api.mailchimp.com/3.0/lists/xxxxxxxx/members",
  
            data: { "email_address":email@adress.com,  "status":"subscribed"},
            headers: {
              "Authorization": "Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==",
              "Content-Type": "application/json"
            },
            success: function(data){
               alert('Thanks for subscribing');
            },
            error: function(data){
              alert('there was an error, try again later');
            }
  });
  </code></pre>
  
  <p>I also Thought on creating my own api and then make the call to mailchimp api but I might ran into the same problem</p>
  
  <p>Do you have any suggestions? </p>
  
  <p>Thanks in advance</p>