title: JSON.parse: unexpected end of data error
body: <p>For the code below i am getting this error :</p>
  
  <p>JSON.parse: unexpected end of data</p>
  
  <p>at line var data = JSON.parse(json);</p>
  
  <p>the code used is:</p>
  
  <pre><code>$(document).ready(function(){  
  $("#button1").click(function(){
      $.post(
          'script_1.php',
          { id: $('input[name="id"]', '#myForm').val() },
          function(json) { 
              var data = JSON.parse(json);
              if (data.length === 0){
               alert('no data');   
              }
              else{
              $("input[name='title']").val(json.title);
                      $("input[name='age']").val(json.age); 
              }},
          "json"
      );
  });
  });
  </code></pre>
  
  <p>the back end php is</p>
  
  <pre><code>$sql ="SELECT * FROM parent WHERE id = '$name'";       
  $result = mysql_query($sql);
  $row = mysql_fetch_array($result);
  if ($row) {
  $row=  array('title' =&gt; $row['title'],'rno' =&gt; $row['reportno'],'url' =&gt;      
  $row['calc_url'], 'institution' =&gt; $row['institution']);
   echo json_encode($row);
   } else {
   echo json_encode(array());
   }
  </code></pre>
  
  <p>What is reason for the error here?</p>