-
7 Jan 2012 9:05 AM #1
Unanswered: Buttons don't return response object on success
Unanswered: Buttons don't return response object on success
I have buttons to submit forms - it appears that the on success handler doesn't return a response object but the failure one does - is this intentional?
I have tested this many times by sending the same response for success/fail and only changing the response code from 200/400Code:onSubmitButtonTap: function(el) { var a = this; var f = this.getForm(); f.submit({ waitMsg: { message: 'Hold on...', cls: 'loading' }, method: 'POST', success: function(frm, res) { //res.responseText does not exist }, failure: function(frm, res) { //this exists res.responseText } });
-
7 Jan 2012 9:41 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 435
- Answers
- 3108
In PR3, the success and failure have the same arguments. The first is the form panel, the second is the response that is decoded so it's a JavaScript Object, the third is the response text undecoded.
Code:form.submit({ success : function(form, resObject, resText) {}, failure : function(form, resObject, resText) {} });Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
7 Jan 2012 9:52 AM #3
Certainly not the case with me in PR3 - the second arg of the success is not a response object - it's just a plain object
-
7 Jan 2012 11:10 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 435
- Answers
- 3108
The 2nd argument is for me and is according to the docs as well. It was the JSON response decoded.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
7 Jan 2012 11:23 AM #5
It is the JSON response decoded - but the failure arg is not - it's a response object.
If I return a json array from my server such as:
{"success":true,"token":"example"}
In success, I access the token like this (assuming my second param is call 'res'):
res.token
In the failure on the other hand I need to do:
res.responseText.token
-
7 Jan 2012 11:25 AM #6Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 435
- Answers
- 3108
If you return success as false, the failure callback should fire and, in my test, it was the decoded JSON string.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
7 Jan 2012 11:48 AM #7
I see the issue - ST doesn't handle a 400 response like a 200. I return a 400 on form fail which does return a different object - evidently this is an issue of sorts
http://www.sencha.com/forum/showthre...ation-response
-
7 Jan 2012 11:53 AM #8
That link I posted above has sencha devs mentioning a possible flag to cause 400 to be parsed. Is this implemented in ST2?


Reply With Quote