title: Serializing and submitting a form with jQuery and PHP
body: <p>I'm trying to send a form's data using jQuery. However, data does not reach the server. Can you please tell me what I'm doing wrong?</p>
  
  <p>My HTML form:</p>
  
  <pre><code>&lt;form id="contactForm" name="contactForm" method="post"&gt;
      &lt;input type="text" name="nume" size="40" placeholder="Nume"&gt;
      &lt;input type="text" name="telefon" size="40" placeholder="Telefon"&gt;
      &lt;input type="text" name="email" size="40" placeholder="Email"&gt;
      &lt;textarea name="comentarii" cols="36" rows="5" placeholder="Message"&gt;&lt;/textarea&gt; 
      &lt;input id="submitBtn" type="submit" name="submit" value="Trimite"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><br>
  JavaScript (in the same file as the above form):   </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $(document).ready(function(e) {
  
          $("#contactForm").submit(function() {
              $.post("getcontact.php", $("#contactForm").serialize())
              // Serialization looks good: name=textInNameInput&amp;&amp;telefon=textInPhoneInput etc
              .done(function(data) {
                  if (data.trim().length &gt; 0) {
                      $("#sent").text("Error");   
                  } else {
                      $("#sent").text("Success");
                  }
              });
  
              return false;
          })
      });
  &lt;/script&gt;
  </code></pre>
  
  <p><br>
  Server side PHP (<em>/getcontact.php</em>):</p>
  
  <p></p>
  
  <pre><code>$nume = $_REQUEST["nume"]; // $nume contains no data. Also tried $_POST
  $email = $_REQUEST["email"];
  $telefon = $_REQUEST["telefon"];
  $comentarii = $_REQUEST["comentarii"];
  </code></pre>
  
  <p><br>
  Can you please tell me what I am doing wrong?</p>
  
  <hr>
  
  <h2>UPDATE</h2>
  
  <p>Checked <code>var_dump($_POST)</code> and it returned an empty array. </p>
  
  <p>The weird thing is that the same code tested on my local machine works fine.
  If I upload the files on my hosting space it stops working. I tried doing an old-fashioned form without using jQuery and all data was correct. </p>
  
  <p>I don't see how this would be a server configuration problem. Any ideas?</p>
  
  <p>Thank you!</p>