-
12 Feb 2009 3:28 AM #21
i've a servlet to process the upload (spring), but how can i access to servlet response to change the contentType to text/html?
-
12 Feb 2009 3:38 AM #22Search 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
-
6 Mar 2009 10:10 PM #23
tried and worked
tried and worked
after several hours of try and error, i got an solution that works in both ie and ff.
in your upload servelet:
response.setContentType("text/html");
response.getWriter().write("{success:true,path:'"+actualFilePath+"'}");
then in your js
form.getForm().submit({
url: '/upload',
waitMsg: 'Uploading your file...',
success: function(fp, o) {
alert(o.result.path)
}})
-
7 Mar 2009 12:43 AM #24
Several hours instead of just reading the API docs?
http://extjs.com/deploy/dev/docs/?cl...form.BasicForm
Originally Posted by TFM
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
-
26 May 2010 7:42 AM #25
A problem arrises if your json response contains html tags:
{"response":{"message":"Unable to <b>parse<\/b> CSV."},"success":false}
Note the escaped forawrd slash '\/' in the Javascript string literal. This string is made with org.json.JSONObject#toString and is the correct string that when eval-ed gives you the correct js object (when using normal Ajax instead of file upload works fine). The problem is once written into the dynamic iframe with the content type of text/html (which avoids the <pre> tags you get with text/plain) the browser realisess this isn't valid html and patches it up so that when you extract it with r.responseText = doc.body.innerHTML; in function cb in Ext.data.Connection.doFormUpload) you end up with:
{"response":{"message":"Unable to <b>parse<\/b> CSV."},"success":false}</b>
When this gets eval-ed Ext expodes (in Ext.util.JSON.decode) with "unterminated regular expression literal" due to the forward slash in the '</b>' the browser inserted on the end of of our text to make it valid html.
-
26 May 2010 7:55 AM #26Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 40
Ext also supports sending the JSON back in a textarea, e.g.
No escaping required as long as your JSON doesn't contain '</textarea>'.Code:<html><body><textarea>{"response":{"message":"Unable to <b>parse</b> CSV."},"success":false}</textarea></body></html>
-
26 May 2010 8:30 AM #27
Thanks for the quick reply Condor.
After writing my post I checked the Ext 3 docs (I'm on Ext 2.2.1) and saw that it does now mention escaping html.
The textarea fix is nice (and I'd always html escape contents to be safe, as Ext gets the .value rather than innerHtml you get right value), but not in Ext 2
. Another reason to upgrade!
-
15 Sep 2011 3:07 PM #28
solved!
solved!
Use the following header when u are sending the response from the server.
header('Content-Type: text/html'); //phpThanks
Surinder singh Mattaur (Matoo)
Extjs Excel copy/paste Grid
Extjs Photo Uploader
Extjs Filter Row
Extjs Grid Query Builder
Extjs Simple Form
Extjs Form Phone Field
Extjs Form Week Field
Sencha Cube Carousel
Sencha Date Picker
Sencha Touch Themes Builder
http://www.developerextensions.com
http://www.developerextensions.net
-
8 May 2012 6:37 AM #29
-
8 May 2012 6:42 AM #30
Apparently Chrome is doing this too and I found the solution:
I switched the repsonse Content-Type on my JSON file to "text/json" instead of "application/json" (only when using the POST method).
It now works fine on my app.My guess is that is a security feature on some browsers.


Reply With Quote
