title: Ajax Call and Returned Response
body: <p>I'm trying to add an address to a list in dotmailer (which for those not familiar is a service like mailchimp) I can get the address added but am struggling to get any sort of returned status via Ajax.</p>
  
  <p>I've got the following in my form page in php</p>
  
  <pre><code>var emailEntered;
  
      $(document).ready(function() {
  
          $.fn.search = function() {
              return this.focus(function() {
                  if( this.value == this.defaultValue ) {
                      this.value = "";
                  }
              }).blur(function() {
                  if( !this.value.length ) {
                      this.value = this.defaultValue;
                  }
              });
          };
          $("#email").search();
  
          $("#sendButton").click(function() {
                  $(".error").hide();
                  var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
                  var emailaddressVal = $("#email").val();
  
                  if(emailaddressVal == '') {
                      $("#message").html('&lt;span class="error"&gt;Enter your email address before submitting.&lt;/span&gt;');
                      return false; 
                  }
                  else if(!emailReg.test(emailaddressVal)) {
                      $("#message").html("&lt;span class='error'&gt;Please check your email address.&lt;/span&gt;");
                      return false; 
                  } 
                  else {
                      emailEntered = escape($('#email').val());
                  }
  
          });
          $('#signup').submit(function() {
              $("#message").html("&lt;span class='error'&gt;Adding your email address...&lt;/span&gt;");
              $.ajax({
                  url: 'dotmailerInput.php',
                  data: 'ajax=true&amp;email=' + emailEntered,
                  success: function(msg) {
                      $('#message').html(msg);
                  }
              });
              return false;
          });
  
      });
  &lt;/script&gt;
  
  &lt;form id="signup" action="dotmailer.php" method="get"&gt;
                  &lt;input type="email" name="email" id="email" class="textinput" value="Enter" /&gt;
                  &lt;input type="submit" id="sendButton" name="submit" class="textinput" value="" /&gt;
              &lt;/form&gt;
              &lt;div id="message"&gt; &lt;/div&gt;
  </code></pre>
  
  <p>In the dotmailer.php page that it is referencing I've got the following. I can see it gives me a response "adding your email address" but nothing else after this and the email as I said gets added correctly.</p>
  
  <pre><code>$email = $_GET['email'];    
  $username = ""; //apiusername
  $password = ""; //api password      
  $addressbookid = ;
  $AudienceType = "Unknown";
  $OptInType = "Unknown";
  $EmailType = "Html";
  
  
  try {
  
  $client = new SoapClient("http://apiconnector.com/api.asmx?WSDL");
  $contact = array("Email" =&gt; $email,"AudienceType" =&gt; $AudienceType, "OptInType" =&gt; $OptInType, "EmailType" =&gt; $EmailType, "ID" =&gt; -1);
  
  $dotParams = array("username" =&gt; $username, "password" =&gt; $password, "contact" =&gt; $contact, "addressbookId" =&gt; $addressbookid);
  $result = $client-&gt;AddContactToAddressBook($dotParams);
  return "Success";
  }
  catch (Exception $e) {
  return "Error";
  }
  </code></pre>
  
  <p>Any helps or tips on what to look at or where to go next would be greatly appreciated.</p>
  
  <p>Chris</p>