View Full Version : submit form in background

30 Dec 2010, 5:36 AM
I probably missed something. I expected that POSTing some form in the background to the server would be a snap with one of world's leading Javascript frameworks. But it wasn't.

The expected easy solution was:

1) create a form, set values
2) submit it

The only solution that finally (after hours) worked (with version 3.2.1):

1) create a FormPanel, set values
2) render() it
3) hide() it immediately after rendering
4) Ajax.request it (required as server would not answer with {success: true} (see also http://www.sencha.com/learn/Manual:RESTful_Web_Services))

Without the rendering step, the form is transmitted, but without fields. Yes, I know, FormPanel and its containing BasicForm are only abstractions. Still, as the form should not be visible to users, there should be an easy and low overhead way (i.e. without rendition step) to achieve this (IMO common) task.

Any suggestions for better patterns?


30 Dec 2010, 6:09 AM
Why do steps 1-3? Step 4 is enough (don't forget to specify the params).

ps. And if you ever consider actually submitting a form then you can use an errorReader if your server doesn't respond with {success:true}.

3 Jan 2011, 2:59 PM
Condor, of course, you are so d'mn right! Thanks.

Not so sure about the errorReader approach. It's an interesting workaround, but certainly would prefer the problem solved at root, i.e. that HTTP status group 200 would be accepted as success by default.