title: Javascript get iframe raw content
body: <p>I have a trouble with Javascript: I created a page like this:</p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  &lt;iframe id="a" src="iframe.php" width="500" height="200"&gt;&lt;/iframe&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>and inside <code>iframe.php</code>, I just echo the JSON string:</p>
  
  <pre><code>&lt;?php
  $json = array(
      'status' =&gt; 'error',
      'html' =&gt; '&lt;span class="cool"&gt;This is a string&lt;/span&gt;'
  );
  
  echo json_encode( $json );
  </code></pre>
  
  <p>What I want is getting the correct raw string echoed by <code>iframe.php</code> using Javascript (maybe jQuery), and parse it as an JSON object.</p>
  
  <p>But the problem is that I always get the wrong content. I tried both the method <a href="https://stackoverflow.com/questions/4575219/how-to-get-whole-content-of-iframe">described here</a> and <code>jQuery('iframe').contents().find('body').html()</code>, but no luck. The <code>span</code> tag is missed or not formatted correctly.</p>
  
  <p>Please help me. Thank you.</p>