title: Why when I send data with POST in AJAX to PHP does it say the variable is null?
body: <p>I have the following jQuery:</p>
  
  <pre><code>$(document).ready(function() {
      $('input[type="submit"]').click(function() {
          event.preventDefault();
  
          var email = $('.email').val();
  
          $.ajax({
              type: "POST",
              url: "register_email.php",
              data: JSON.stringify({ "email": email }),
              dataType: "json",
              contentType: "application/json",
              success: function(data) {
                  alert(data);
              },
              error: function(jqXHR, textStatus, errorThrown) {
                  alert(textStatus + " " + errorThrown);
              }
          });
      });
  });
  </code></pre>
  
  <p>The <code>email</code> variable is definitely set, I can <code>alert</code> it out.</p>
  
  <p>However, when I get to the PHP, this is my script:</p>
  
  <pre><code>&lt;?php
      $db = new mysqli("localhost", "...", "...", "...");
  
      if ($db-&gt;connect_error) {
          echo "Could not connect to database.";
          exit;
      }
      else {
          $emerd = json_decode($_POST["email"]);
  
          $db-&gt;query("INSERT INTO emails (email) VALUES (' " . $emerd . "')");
  
          echo $emerd;
      }
  ?&gt;
  </code></pre>
  
  <p>It always alerts "null" back to me. Why won't it understand what I'm POSTing?</p>