title: JSON.parse Unexpected character
body: <p>I have a JSON object stored in a mongoDB collection. The object represents the positions of 5 x images, 5 y images, and a tictactoe board image.</p>
  
  <p>On an interval, I send a request to a php file that responds with this object, and then I want to parse that object and move the pieces accordingly.</p>
  
  <p>this is my request:</p>
  
  <pre><code>$.getJSON
  (
      "e4.php",
      "",
      function(data)
      {
          world = JSON.parse(data);
          moveObjects(world);
      }
  );
  </code></pre>
  
  <p>but I get: JSON.parse: unexpected character </p>
  
  <p>When I console.log data firebug gives me the right object so I know it's returning properly.</p>
  
  <p>In e4.php:</p>
  
  <pre><code>$criteria = array("name" =&gt; "world");
  
  $doc = $collection-&gt;findOne($criteria);
  
  $conn-&gt;close();
  
  print $doc['world'];
  </code></pre>
  
  <p>where conn is the connection, and collection is the collection I'm working in.</p>
  
  <p>The database is updated in e3.php:</p>
  
  <pre><code>$encodedworld = $_REQUEST['data'];
  
  $criteria = array("name" =&gt; "world");
  
  $doc = $collection-&gt;findOne($criteria);
  
  $doc['world'] = $encodedworld;
  
  $collection-&gt;save($doc);
  
  $conn-&gt;close();
  
  print $encodedworld;
  </code></pre>
  
  <p>Any ideas? I'm stumped</p>
  
  <p>Thanks in advance.</p>