I am debugging our file uploading script, which uses a hidden iframe in browsers that do not support sending file data via an XMLHttpRequest object.
There is a ple
photo_upload.json
IS being downloaded into the iframe, but because the browser doesn't know what to do with it, it assumes it to be a file for download.
Ideally, you should have the iframe receive HTML data, which may contain a <script>
to tell the parent window what to do. Alternatively, if you already have code in the parent to handle receiving the response (which it looks like you do), set Content-Type: text/html
on the response to force the browser to treat it as an HTML document - it will automatically add the basics like an <html>
tag and a <body>
tag, so just access iframe.contentDocument.body.innerHTML
.