title: Wordpress ajax contact form doesn't return data
body: <p>I'm making a WordPress theme where every post will have a contact form. The contact form will collect information about the visitor and send a mail to the site administrator. It will also send an email to the visitor with a link to a downloadable PDF (this code is not done yet).</p>
  
  <p>The problem I have is that the php function that handles the ajax form doesn't respond. It only returns a -1 (No Properties). But I get a status code 200 OK. </p>
  
  <p>I'm running the dev server on MAMP Pro OSX and DynDNS. </p>
  
  <p><strong>This is the PHP I have in functions.php</strong></p>
  
  <pre><code>function ajax_contact() {
  
    if(!empty($_POST)) {
    $name = $_POST['name'];
    $company = $_POST['company'];
    $mail = $_POST['mail'];
    $admin_mail = get_bloginfo('admin_email');
    $error = "";
    if(!$name) {
        $error .= "Please tell us your name&lt;br/&gt;";
    }
    if(!$company) {
        $error .= "Please tell us your company&lt;br/&gt;";
    }
    if(!$mail) {
        $error .= "Please tell us your E-Mail address&lt;br/&gt;";
    }
  
    if(empty($error)) {
        $subject = "New download notification";
        $message = "You've received a new download notification. \n\n
            Name: ".$name."\n
            Company: ".$company."\n
            Mail: ".$mail."\n";
  
        // Send a mail to the admin with the contact info.    
        $send_mail = wp_mail($admin_mail, $subject, $message);
  
        // Send mail to visitor with the download link.
  
        if($send_mail) {
        echo "sent";
        die();
        }
  
    } else {
        echo "error: " . $error;
        die();
      }
    }
  }
  
  add_action('wp_ajax_nopriv_ajax_contact', 'ajax_contact');
  add_action('wp_ajax_ajax_contact','ajax_contact');
  </code></pre>
  
  <p><strong>This is the javascript code</strong></p>
  
  <pre><code>    function sendForm(formId, postId, str)
  {
  
      console.log("formId: " + formId);
      console.log("formId: " + postId);
      console.log("str: " + str);
  
      $.ajax({
          type: "POST",
          url: "../wp-admin/admin-ajax.php",
          action: "ajax_contact",
          data: str,
          success: function(data) {
  
              $("#" + formId).ajaxComplete(function(event, request, settings){
  
              if(data == 'sent') {
                  $("#" + formId).find(".success").fadeIn("slow");
                  }
                  else {
                  result = data;
                  $("#" + formId).siblings(".success").html(result);
                  }
              });
  
          }
      });
  
  
  }
  </code></pre>
  
  <p><em><strong>And this is the actual form (I have multiple forms on the same page)</em></strong></p>
  
  <pre><code>&lt;form name="form-&lt;?php the_ID(); ?&gt;" id="form-&lt;?php the_ID(); ?&gt;"/&gt;
      Name &lt;br/&gt; 
      &lt;input type="text" name="name" value=""/&gt;&lt;br /&gt;
      Company / Organisation &lt;br/&gt; 
      &lt;input type="text" name="company" value=""/&gt;&lt;br /&gt;
      Email &lt;br/&gt; 
      &lt;input type="text" name="mail" value=""/&gt;&lt;br /&gt;
  
      &lt;input type="hidden" name="postId" value="&lt;?php the_ID(); ?&gt;"&gt;
  
      &lt;input type="submit" value="submit" class="requestbutton" id="requestButton-&lt;?php the_ID(); ?&gt;" rel="&lt;?php the_ID(); ?&gt;"/&gt;
    &lt;/form&gt;
  </code></pre>
  
  <p><strong>EDIT: Changed the ajax action name, problem still persists</strong></p>