Hybrid View
-
5 Nov 2007 12:36 PM #1
<pre>json</pre> in File upload response (FF only)
<pre>json</pre> in File upload response (FF only)
I'm actually not 100% sure if this is an Ext bug or not, but I'm having problems with the following code (essentially handling a File Upload through a Ext.Window):
Console reports:Code:// ignore ${auto_var} -- it is part of a code generator var ${auto_var}_form = new Ext.form.FormPanel({ frame : true, defaultType : 'textfield', waitMsgTarget : true, bodyStyle : 'padding:5px 5px 0', labelAlign : 'left', buttonAlign: 'right', fileUpload : true, enctype : 'multipart/form-data', items : [ { fieldLabel : 'Attachment', inputType : 'file' } ] }); var ${auto_var}_submit = ${auto_var}_form.addButton({ text:"Submit", handler: function() { ${auto_var}_form.form.submit({ url:'upload', waitMsg : "Uploading...", success: function(f,a){ console.log(a); } }); } })
I know for 100% that I am not returning <pre> tags.Code:[Break on this error] (<pre>{success:true}</pre>)
What is happening, I think, is that because the response happens in an IFRAME (because of File Upload, I presume), Firefox is automatically wrapping the response in a DOM, then the IFRAME content is pulled out and eval'ed.
My Spring controller simply returns:
I've tried application/json, but this just prompts a File/download dialog.Code:res.setHeader("Content-type","text/javascript"); res.getWriter().write("{success:true}"); return null;
The only fix I can think of is edit Ext's decode function to handle the <pre> tags:
Any suggestions??Code:this.decode = function(json){ // check if there are <pre> tags and strip them out. return eval("(" + json + ')'); };
-
5 Nov 2007 6:49 PM #2
you should modify method 'decode' to get rid of tag '<pre> </pre>'.
and then everything will work well.
but i gotta another problem, uploadform works fine in FF, but fails in IE6.0.
IE cannot submit any request to ther server, and throw some js exception.
could you give me any clue??
-
15 Jan 2008 9:33 AM #3
Any body know if this bug is going to be solve?
Because I have the same issue <pre>...</pre>.
And i think it's not clean to get rid of tag '<pre> </pre>'.
And it doesn't look work on IE6
Please the Ext team help us.... ;-)
-
15 Jan 2008 9:38 AM #4
Uploads are done using a form submit which loads an iframe.
It's expecting an HTML document. It gets the "responseText" by extracting the innerHTML of the document. That's what FF puts there. It wraps plain text responses with <pre> tags.
There was a long discussion about this with several workaruonds posted, but the dev team have not looked at it.Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
25 Mar 2008 3:50 AM #5
Has any "official" method of getting around this surfaced yet? I too am facing this (rather annoying) problem.
-
25 Mar 2008 4:09 AM #6
I do file uploads and I have never had this problem, it is all in the way you return the JSON formatted response, for whatever reason, the method being used her is wrapping it in <pre></pre> tags. If you don't return it with that then there is no problem. It isn't a bug.


Reply With Quote