title: Submitting JSON struct to MailChimp API via HTML form + JavaScript
body: <p>Appreciate your help on what I'm sure is a real basic head-slapper. I'm setting up a simple web front-end so that I can check if an email address is already a subscriber to an existing MailChimp list. For now I'd like to just use basic HTML &amp; JavaScript.</p>
  
  <p>My MailChimp API Key checks out, and I can run queries that only require string data, but the relevant API call requires a struct for email address(es), and I keep getting an error in any variation of the code below. I've gone as far as installing node.js and just running that from the command line and the query does work with the same data, so I'm sure I'm just <em>this</em> close, but need your help to get over the hump.</p>
  
  <p>Here is the relevant snippet of the script and form. As written, I receive the following error message in reply: Validation error: {\"email\":\"Please enter a struct\/associative array\"}"}</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  function collectAndSubmit() {
          var emailAddy = document.getElementById("emailAddy").value;
          var JSONemail = {"email":
                              {
                                  "email": emailAddy
                              }
                          };
          document.getElementById("email").value = JSONemail;
          document.getElementById("apikey").value ="M*Y*A*P*I*K*E*Y"
          document.testform.submit();
  }
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form action="https://us2.api.mailchimp.com/2.0/helper/lists-for-email" method="post" name="testform"&gt;
      Email Address: &lt;input type="text" id="emailAddy" name="emailAddy" /&gt;
      &lt;input type="hidden" id="apikey" name="apikey" /&gt;
      &lt;input type="hidden" id="email" name="email" /&gt;
      &lt;br&gt;
      &lt;input type="button" value="Check Email" onclick="collectAndSubmit()" /&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Thanks in advance for your help.</p>