title: Submitting JSON data via JQuery ajax.post to PHP
body: <p>Im submitting Data to a php file via AJAX using POST.
  It worked fine with just submitting strings, but now I wanted to submit my JS Object with JSON and decode it on PHP side.</p>
  
  <p>In the console I can see, that my data is submitted correctly but on PHP side json_decode returns NULL.</p>
  
  <p>I've tried the following:</p>
  
  <pre><code>this.getAbsence = function()
  {
      alert(JSON.stringify(this));
      jQuery.ajax({
          type: "POST",
          contentType: "application/json; charset=utf-8",
          url: "ajax/selectSingle.php?m=getAbsence",
          data: JSON.stringify(this),
          success : function(data){
              alert(data);
          }
      });
  }
  </code></pre>
  
  <p>PHP:</p>
  
  <pre><code>echo $_POST['data'];
  echo json_decode($_POST['data']);
  echo var_dump(json_decode($_POST['data']));
  </code></pre>
  
  <p>And:</p>
  
  <pre><code>this.getAbsence = function()
  {
      alert(JSON.stringify(this));
      jQuery.ajax({
          type: "POST",
          contentType: "application/json; charset=utf-8",
          url: "ajax/selectSingle.php?m=getAbsence",
          data: {'Absence' : JSON.stringify(this)},
          success : function(data){
              alert(data);
          }
      });
  }
  </code></pre>
  
  <p>PHP:</p>
  
  <pre><code>echo $_POST['Absence'];
  echo json_decode($_POST['Absence']);
  echo var_dump(json_decode($_POST['Absence']));
  </code></pre>
  
  <p>The alert was just to check everything is alright...</p>
  
  <p>And yea usual string were echoed correctly :-)</p>