-
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.
-
25 Mar 2008 5:41 AM #7
No, it really is a bug, I know for a fact that my returned json is *not* wrapped in any tags (I have checked and double checked). It seems to be the way Firefox handles content sent to the iframe used to do a file form submit. Fiddling with the response headers either triggers a file download box or the bug. Although, come to think of it, I have yet to try sending it as text/plain (which I'd rather not, seeing as how it's not correct)
-
25 Mar 2008 5:50 AM #8
Interesting, well I will take back what I said, though I haven't seen this problem in my setup, I will have to mess around with it and see if I can duplicate, I suppose for now as suggested earlier, just strip the html tags before decoding.
-
25 Mar 2008 6:22 AM #9
my search skills seem to have deserted me:
http://extjs.com/forum/showthread.php?t=8129
had the answer
-
25 Mar 2008 8:11 AM #10
Ah, I'd forgotten the conclusion there, and it's very useful. I will update the documentation to make this absolutely plain!
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


Reply With Quote