I am using ajax_upload for uploading files without a postback of the entire page.
The server is returning the response as XML that I then parse in my onComplete function, this works in Chrome, Safari and Firefox but not in Internet Explorer. The reason for this not working in Internet Explorer (at least what I think is the reason) is that IE parses the XML in the iframe and displays it with syntax highlighting and all even though the iframe is set to size 0.
When ajax_uploads then reads the iframe it gets a corrupted version of the XML that I am unable to parse with $.parseXml() because of the syntax highlighting that IE adds to it.
I have Googled and found mentions of using iframe.document.XMLDocument to get the raw XML from the iframe but it didn’t work for me and the posts mentioning it was realy old.
So the question is, does anybody know how to get the XML data from the iframe without the syntax highlighting done by IE (that it does by adding HTML and escaping the tags in my XML) or is there a way to tell IE not to parse the XML in a HTTP header or something like that?
I thought
Content-Type: text/plaincould help in fixing this issue, but this only helps in other browsers. IE has its own way to detecting content type, and this behavior cannot be easily disabled. More information on this available at MSDN and more briefly here.Of course you could make a dirty hack like this:
And parse highlighted code:
This works in IE6-8, but this way is unreliable 🙂 So I suggest you using JSON instead of XML if possible to avoid this issues.