View Full Version : Form submit success/failure callback invocation

17 Feb 2012, 5:09 AM
The manual states (http://docs.sencha.com/ext-js/4-0/#!/api/Ext.form.Basic-method-submit) that in order to trigger a call of your success handler function, you need to package your response in a JSON object that has a 'success:true' property. This is different from the way Ext 3 handles it, which is a lot more elegant in my opinion. Ext 3 automatically calls the failure handler upon receiving an HTTP-500 response from the server, and the success handler otherwise. This worked very well for me, as I threw Exceptions in PHP and converted those to JSON objects with a HTTP-500 header.

Is there a specific reason this behavior was changed? Or am I overlooking something?

17 Feb 2012, 5:12 AM
So if you have status code 200 and JSON of { "success" : true, ... } it will fire the success handler. If you have a code 200 and { "success" : false } it will fire the failure handler. If you have a code like 400 and { "success" : true } it will fire the success handler?

17 Feb 2012, 5:55 AM
My point is more that no handler is being fired when there is no 'success' key in the response. So I'm tied to this response format of an object with a success property. Which I think is redundant, because we can infer that from the HTTP response code (like happened in Ext 3). This allows for smaller and more elegant responses and more efficient use of the HTTP protocol (the object-with-success-property adds a lot of overhead if say you just want to return an ID).