title: Parsing xml/json response in IE9
body: <p>I thought this issue <a href="https://stackoverflow.com/questions/9746515/ie9-refuses-to-process-xml-response">was resolved</a> but unfortunately it's not, although it seems to be a different problem this time.</p>
  
  <p>I want to use imgur API photo sharing service via cross domain XHR, and apparently, it works fine. I start a request, they send an xml and all I need to do is processing that. However, I can't do it properly in Internet Explorer 9 despite multiple suggestions (works in Chrome, Firefox). This is the most simple code I tried:</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
    &lt;html&gt;
      &lt;body&gt;
      &lt;form id="uploadForm" action="http://api.imgur.com/2/upload.xml" method="POST" enctype="multipart/form-data"&gt;
      &lt;input type="hidden" name="key" value="00ced2f13cf6435ae8faec5d498cbbfe"/&gt;
      File: &lt;input type="file" name="image"/&gt;
      Return Type: &lt;select id="uploadResponseType" name="mimetype"&gt;
      &lt;option value="xml"&gt;xml&lt;/option&gt;
      &lt;/select&gt;
      &lt;input type="submit" value="Submit 1" name="uploadSubmitter1"/&gt;
      &lt;/form&gt;
      &lt;div id="uploadOutput"&gt;&lt;/div&gt;
      &lt;/body&gt;
    &lt;/html&gt;
  </code></pre>
  
  <p>There you can see a key to Imgur API (you can use it, if you want... it's only for testing purposes, but I don't thing there is anything wrong with the xml response I receive).</p>
  
  <p>I'm using <a href="http://malsup.com/jquery/form/#file-upload" rel="nofollow noreferrer">Jquery Form Plugin</a> to manage the file uploads. </p>
  
  <p><strong>XML:</strong></p>
  
  <hr>
  
  <p>This is the simplest piece of code that I have tested. Usually, we need to help Internet Explorer to parse xml independently, that's why I have parseXml.</p>
  
  <p>Javascript:</p>
  
  <pre><code>function parseXml(xml) {  
    if (jQuery.browser.msie) {  
      var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");  
      xmlDoc.loadXML(xml);  
      xml = xmlDoc;  
    }  
    return xml;  
  } 
  
  $('#uploadForm').ajaxForm({
      dataType: ($.browser.msie) ? "text" : "xml",
      accepts: {
          xml: "text/xml",
          text: "text/xml"
      },
      // has been received
      success: function(data) {
          $('#uploadOutput').html('Submitting...');
          data = parseXml(data);
          console.log(data);
          alert(data);
      },
      complete: function(data) {
          $('#uploadOutput').html('Complete...');
       }
  });
  </code></pre>
  
  <p><code>dataType: ($.browser.msie) ? "text" : "xml"</code> supposedly tells IE to return a text response. Despite all these assurances, the <code>Content Type</code> of the response is <code>application/xml</code> (I was told that wasn't a problem). As an xml I receive this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;upload&gt;&lt;image&gt;&lt;name/&gt;&lt;title/&gt;&lt;caption/&gt;&lt;hash&gt;087Y0&lt;/hash&gt;&lt;deletehash&gt;gUcgywjXoJyAJp6&lt;/deletehash&gt;&lt;datetime&gt;2012-06-02 21:59:35&lt;/datetime&gt;&lt;type&gt;image/jpeg&lt;/type&gt;&lt;animated&gt;false&lt;/animated&gt;&lt;width&gt;1024&lt;/width&gt;&lt;height&gt;768&lt;/height&gt;&lt;size&gt;297623&lt;/size&gt;&lt;views&gt;0&lt;/views&gt;&lt;bandwidth&gt;0&lt;/bandwidth&gt;&lt;/image&gt;&lt;links&gt;&lt;original&gt;http://i.imgur.com/087Y0.jpg&lt;/original&gt;&lt;imgur_page&gt;http://imgur.com/087Y0&lt;/imgur_page&gt;&lt;delete_page&gt;http://imgur.com/delete/gUcgywjXoJyAJp6&lt;/delete_page&gt;&lt;small_square&gt;http://i.imgur.com/087Y0s.jpg&lt;/small_square&gt;&lt;large_thumbnail&gt;http://i.imgur.com/087Y0l.jpg&lt;/large_thumbnail&gt;&lt;/links&gt;&lt;/upload&gt;
  </code></pre>
  
  <p>I think it looks ok and I can parse it in other browsers using something like <code>$($.parseXml(xml)).find('original').text()</code>, but not in IE9. So basically, I'm receiving a response but I can't parse that xml, although when I try to figure out what I'm getting in IE, looks like I get nothing.</p>
  
  <p>Furthermore, <code>success</code> is not even firing which is a signal that IE9 couldn't parse the xml. <code>complete</code> is firing but it doesn't receive anything as <code>data</code>. So what am I doing wrong?</p>
  
  <p>Here you can have a <a href="http://jsfiddle.net/7sYF2/" rel="nofollow noreferrer">fiddle</a> (includes Jquery Form Plugin).</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p><strong>JSON</strong></p>
  
  <hr>
  
  <p>For future reference, JSON will not work using Jquery Form Plugin in this situation. From the documentation:</p>
  
  <pre><code>The iframe element is used as the target of the form's submit operation 
  which means that the server response is written to the iframe. This is fine 
  if the response type is HTML or XML, but doesn't work as well if the response 
  type is script or JSON, both of which often contain characters that need to 
  be repesented using entity references when found in HTML markup. To account 
  for the challenges of script and JSON responses when using the iframe mode, 
  the Form Plugin allows these responses to be embedded in a textarea element 
  and it is recommended that you do so for these response types when used in 
  conjuction with file uploads and older browsers.
  </code></pre>
  
  <p>Ideas?.</p>
  
  <p>Thanks!</p>