PDA

View Full Version : [FIXED] Callback not called when submitting form



dlouwers
22 Oct 2011, 5:25 AM
Hi,

When the AJAX request for submitting an Ext.form.Panel is successful (a HTTP header 200 OK is returned) but the responseText does not contain the JSON element { success: true }, no callback is called. In Sencha Touch 1 the failure callback is called in this case.
One could argue that this case should never occur because according to REST a header in the 400 range should be returned, but I think that many webservices do not support this and do return a 200 header. I therefore suggest that the behaviour from version 1 is restored.

Here are the relevant code snippets from Sencha Touch 2 (Ext.form.Panel):



if (success) {
response = Ext.decode(responseText);
success = !!response.success;
if (success) {
if (Ext.isFunction(options.success)) {
options.success.call(options.scope || me, me, response, responseText);
}
me.fireEvent('submit', me, response);
}
}
else {
if (Ext.isFunction(options.failure)) {
options.failure.call(options.scope || me, me, response, responseText);
}
me.fireEvent('exception', me, response);
}

... and Sencha Touch 1 (Ext.form.FormPanel):



if (success) {

response = Ext.decode(responseText);
success = !!response.success;

if (success) {
if (Ext.isFunction(options.success)) {
options.success.call(options.scope || this, this, response, responseText);
}

this.fireEvent('submit', this, response);
return;
}
}

if (Ext.isFunction(options.failure)) {
options.failure.call(options.scope || this, this, response, responseText);
}

this.fireEvent('exception', this, response);

Jamie Avins
31 Oct 2011, 11:05 AM
Sounds like a bug, thank you for the report.