title: How to get the response data in ajax call
body: <p>I have a php file(index.php) with two fields when i post that form, in javascript i am doing form data serialize and send it to next php page(results.php) through ajax. When i try to print the data inside success it is not printing. FInd the below code.</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;&lt;/title&gt;
      &lt;script src="../scripts/jquery-1.9.1.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form method="post" name="index" id="indexform"&gt;
          &lt;table border="1"&gt;
              &lt;tr&gt;
                  &lt;td&gt;Name:&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" name="fname"&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;Email:&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" name="email"&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td colspan="2"&gt;&lt;input type="submit" name="sendData"&gt;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;script type="text/javascript"&gt;
      $( "#indexform" ).on( "submit", function( event ) {
            event.preventDefault();
            console.log( $(this).serialize() );
            var formdata = $(this).serialize();
           // alert(formdata);
            $.ajax({
                  type:"POST",
                  url:"result.php",
                  dataType:'json',
                  data:formdata,
                  success: function(data){
                      alert(data);
                  }
            });
          });
      &lt;/script&gt;
  </code></pre>
  
  <p></p>
  
  <p>In the above i cant print the data inside the success callback.</p>