title: How to convert form data into JSON (Beginner) in jquery?
body: <p>I am trying to send data using AJAX to PHP page. I am getting all the data from the form and I am trying to convert it to JSON. However, <code>.stringify()</code> doesn't do the job for me.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>&lt;script&gt;
          $(document).ready(function(){
  
              console.log("Ready..");
  
              $("#profile-form").submit(function(event){
                  var data = $(this).serialize();
                  console.log(JSON.stringify(data));
  
                  $.ajax({
                      type    : "POST",
                      url     : "profile.php",
                      data    : JSON.stringify(data),
                      success : function(response){
                          alert(response);
                      }
                  });
              });
  
              //$("#profile-form").submit();
          });
  &lt;/script&gt;
  </code></pre>
  
  <p>I am able to see the form-data on the console. However, I am not getting any JSON data on the server. I have just done <code>print_r($_POST['data'])</code> in my <code>profile.php</code> page. However, it says variable data not defined.</p>