View Full Version : doFormUpload breaks in IE7, Ext.decode

13 Jul 2009, 11:13 AM
IE7, and perhaps others, is putting newlines into the doc.body.innerHTML when a form is submitted by AJAX and a form's fileUpload property is set, which results in the JSON response being broken.

For example, the following response

{success: true, html: '<div>A response with some newlines. </div>', message: 'Test' }

Will be transformed into the following.

{success: true, html: '
<DIV>A response with some newlines. </DIV>', message: 'Test' }

Although the newlines that I've made have been escaped on the server, IE tends to put newlines around tags.

Is this something that other people have seen?

The hack is to escape newlines in the decode method ( actually Ext.util.JSON.doDecode() ).

//Hack to get ExtJS to load json correctly in IE
Ext.decode = function(json)
json = json.replace(/(\r\n|\n|\r)/g, '\\n');
return eval("(" + json + ')');