title: How can I redirect HTML form submission to an iframe?
body: <p>I'm trying to implement a workaround to the problem of using AJAX with multi-part form data. <a href="http://www.openjs.com/articles/ajax/ajax_file_upload/" rel="nofollow">This page</a> looks like a good idea.  Bascially, instead of using AJAX you redirect the output of the form submission to an iframe.  However, it isn't quite working for me.  Here's my client-side HTML code:</p>
  
  <pre><code>&lt;form id="submitDocumentForm" target='upload_target' name="submitDocumentForm" enctype="multipart/form-data" action="MyServlet" method="POST"&gt;
     &lt;input id="inputFile" type="file" name="inputFile"/&gt;
     &lt;input type="submit" value="Import Document" /&gt;
     &lt;iframe id="upload_target" name="upload_target" src="" style="width:100;height:100;border:0px solid #fff;"&gt;&lt;/iframe&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>The server side processing seems to work fine, but the client side response (IE7) is to pop up a File Download "Do you want to save this file, or find a program..." dialog box.  Here's the relevant server side Java code:</p>
  
  <pre><code>//handling of the file and exception handling omitted
  JSONObject responseData = new JSONObject();
  responseData.put("messages", "Upload complete");
  PrintWriter pw = response.getWriter();
  response.setHeader(RESP_HEADER_CACHE_CONTROL, RESP_HEADER_VAL_NO_CACHE);
  response.setContentType("application/json");
  pw.println(responseData.toString());
  pw.close();
  </code></pre>
  
  <p>Any suggestions as to how I might fix this?  Many thanks in advance.</p>