I am simulating an asynchronous file upload by targeting an iframe, like so:
<form id="upload_form" action="upload.php" method="POST" enctype="multipart/form-data" target="upload_iframe">
<input type="file" name="upload_input" />
<iframe id="upload_iframe" name="upload_iframe" src=""></iframe>
</form>
After a file is selected, the form is submitted like so (using jQuery):
$('#upload_input').change(function() {
$('#upload_form').submit();
});
The file is uploaded, and the JSON response is sent to the iframe. In Firebug, I can see that the iframe's content is:
<html>
<head></head>
<body>{"success":true}</body>
</html>
I am using the iframe's load event to wait for the response. The load event is firing. (It actually fires twice, which is a minor issue.) However, I can't figure out how to read the response. I have tried various calls, but none of them return anything:
$('#upload_iframe').find('body')
$('#upload_iframe').html()
$('#upload_iframe').text()
Is there something I am missing?