title: How to capture the refresh inside of an iframe from parent document?
body: <p>Here's the case:
  We have a file upload page. We didn't want to reload the page once the upload is done, so we put the form inside of an iframe. The form inside of an iframe posts to itself and returns json when it's done. How can we capture that response? When upload is done, the iframe reloads, so in other words, how do we capture when the iframe is reloaded?</p>
  
  <p>Assume these:</p>
  
  <ul>
  <li>we cannot print/return anything except the json object (so no js code to call the function in a parent document.)</li>
  <li>we cannot use ajax since you cannot post files using ajax</li>
  <li>we cannot append javascript code inside of iframe, because once the form inside of iframe is submitted, the page gets reloaded and we lose the appended js code.</li>
  </ul>
  
  <p>Any ideas?</p>
  
  <p><strong>UPDATE</strong> - Seems like the solution is super simple (found it somewhere online):</p>
  
  <pre><code>&lt;iframe onload="alert(window['upload_iframe'].document.body.innerHTML);"  ...&gt;&lt;/iframe&gt;
  </code></pre>
  
  <p>This way, it will fire the alert whenever page inside of an iframe is reloaded. Now it's just matter of differentiating JSON object from HTML code, which is pretty simple. Thanks for everyone for a great advises!</p>