title: How to decode a json object sent through jquery ajax method in php file?
body: <p>This is the jquery ajax part in which i have sent json data to the php file.</p>
  
  <pre><code>$(function () {
   $('form').submit(function () {
     var fields = $(this).serializeArray();
     var ans_json = JSON.stringify(fields);
     console.log(ans_json);
  
     $.ajax({
       url: "results.php",
       type: "POST",
       data: ans_json,
       dataType: "json",
       success: function (result) {
         console.log(result);
       }
     });
     return false;
   });
  });
  </code></pre>
  
  <p>Now i want to use this json data sent to the php page.How can i do it? I have done it this way but it returns null.</p>
  
  <pre><code>&lt;?php
     echo json_decode('ans_json');
  ?&gt;
  </code></pre>
  
  <p>I have a set of 10 questions which need to be answered. 3 questions were answered so got the below result.This is what i got in my console.</p>
  
  <pre><code> [{"name":"answer_9","value":"a"},{"name":"answer_10","value":"a"}] quizzes.php:14
  </code></pre>
  
  <blockquote>
    <p>null </p>
  </blockquote>