title: Decode JSON POST in php
body: <p>I am using <code>dataType:'json'</code> and <code>data: {'post':val}</code> in my ajax to send the data to my php file. <code>val</code> in <code>data: {'post':val}</code> is a variable.<br>
  The data sent to the php file is <code>[object Object]</code> so, before assigning it to a php variable, I need to decode it. I am new to JSON and don't know much.<br>
  I tried <code>$id=$_POST['post'];</code> but that doesn't work since the sent data is in JSON format.<br>
  How do I send <em>'normal'</em> data or decode the data whithout removing <code>dataType:'json'</code> as my php file has an array which is sent back to ajax by <code>json_encode</code><br>
  <br>
  Note: the value is perfectly assigned when in the Ajax. (When I alert it with <code>alert({post:val}['post']);</code> the result shown is what I assigned).<br><br>Hmm .. Here is my <strong>Updated</strong> Ajax (I accidentally posted a wrong one in previous code):-<br></p>
  
  <pre><code>function op_prof(obj) {
      var xval = obj.id;
      var dataString = "{'u_search':'"+xval+"'}";
  
      $.ajax({
      type: "POST",
      url: '/script/profile.php',
      data: dataString,
      dataType: 'json',
      cache: false,
      success: function(data) {
          console.log(data);
      }
    });
  };
  </code></pre>