PDA

View Full Version : [CLOSED]xtype filefield response error



navvn
18 May 2011, 12:49 AM
I have a simple form with one field


{
xtype: 'filefield',
name: 'upfile',
buttonText: 'Select file...'
}
After submit there is a POST to the server:

source_moduleticketsupfile?PNG ??? IHDR??? ETC
and response

{"data":{"ident":"01000L4GOBD2ZXIDT9511NZ0KLOAXGVPGILSUFZ9G527SAAC6","filename":"Error","extension":"png","size":"1097"},"success":true}

At this point i got an error from EXTJS


msg"You're trying to decode...></ul>}</div></doctype>"
sourceClass"Ext.JSON"
sourceMethod"decode"Firebug shows that response is JSON and it's valid.
Any idea how to solve this?
Other POST queries with only textfields/combo works fine. But with filefield doesn't.

evant
18 May 2011, 2:04 AM
See info here: http://dev.sencha.com/deploy/ext-3.3.1/docs/?class=Ext.form.BasicForm

Looks like it may have been omitted accidentally from the 4.0 docs. Does it resolve your issue?

navvn
18 May 2011, 10:01 PM
See info here: http://dev.sencha.com/deploy/ext-3.3.1/docs/?class=Ext.form.BasicForm

Looks like it may have been omitted accidentally from the 4.0 docs. Does it resolve your issue?

According to this example http://dev.sencha.com/deploy/ext-4.0.0/examples/form/file-upload.html my old form config was ok but I'v change it to:



var config = {
frame: true,
border: false,
url: '/files/upload',
fileUpload: true,
bodyPadding: 10,
standardSubmit: false,
method: 'POST'

};

still doesnt work.

I'v notice also one more thing. Firebug in Your example respond not only JSON but also HTML. Is that nessesary? (check attachments)
26137
26138

evant
18 May 2011, 11:00 PM
The bit about setting the content type of the response.

navvn
22 May 2011, 11:06 PM
well yeah, my bad. Thought it could work with json.
Anyway changing content type to html made my form work as intended.
Cheers.

rrandymeyer
1 Jun 2011, 1:58 PM
I am running into the same issue when using Struts2. Not sure how to configure Struts2 to return the contentType of text/html. I have tried to implement it like in this example: http://struts.apache.org/2.0.14/docs/how-can-we-return-a-text-string-as-the-response.html. (http://struts.apache.org/2.0.14/docs/how-can-we-return-a-text-string-as-the-response.html)

Has anyone had success with Struts2 and the filefield response?

Thank you.

rrandymeyer
2 Jun 2011, 6:38 AM
I found this worked:



<result type="json">
<param name="contentType">text/html</param>
</result>