title: calling Json data returns undefined "
body: <p>When I call json object from php file  it returns undefined. I can see all data writing <code>alert(data)</code> but when I write  alert(data.books) it returns undifined.  </p>
  
  <pre><code>$JSON = '
  
  {
    "books": {
   "book1": "firstbook",
   "book2": "secondbook"
    }
    }
  ';
  </code></pre>
  
  <p>and I call it with jquery </p>
  
  <pre><code>jQuery('#login').live('submit',function(event) {
  
  
  $.ajax({
      url: 'lib/login.php',
      type: 'POST',
      dataType: 'json',
      data: $('#login').serialize(),
    success: function(data ) {
  
  alert(' ' +data.books);
  
    if(data.books.book1){  
  alert("OK"); 
  }else
  {
  alert("error");   
  }
  }
  
   });
  
     return false;
  
  
  });
  </code></pre>
  
  <p><strong>EDIT</strong>
   This is how it returns alert(data)  </p>
  
  <pre><code>    {
  
    "books": {
  
    "book1": "firstbook",
  
    "book2": "secondbook"
  
  }
  
  }
  </code></pre>