title: Reading json object sent via ajax in php file
body: <p>I am trying to solve one problem with reading json object sent via ajax request in php file and I am keep gettin null in the console. </p>
  
  <p>Javascript file</p>
  
  <pre><code>//create function to send ajax request
  function ajax_request(){
    console.log("hello");
   var post_data = {
      "news_data" : 'hello',
      "news_date" : '1st march'
  }
  $.ajax({
      url : 'index.php',
      dataType : 'json',
      type : 'post',
      data : post_data,
      success : function(data){
          console.log(data);
      }
   });
  }
  
  //on click event
  $('#news_post_button').on('click', ajax_request);
  </code></pre>
  
  <p>and php file which is only for testing to see what i get</p>
  
  <pre><code>&lt;?php
   header('Content-Type: application/json');
  
  
  
    $aRequest = json_decode($_POST);
  
    echo json_encode($aRequest[0]-&gt;news_data);
  
  ?&gt;
  </code></pre>