I can't seem to ever get a success return after submitting a form. The response back to Sencha is valid JSON with the success tag set to true, but no matter what I try the failure action is always taken.
I would be very grateful if someone could point me in the right direction. I've googled like mad to try and work this out.
Many thanks
I'm running Sencha Touch 1.1.0
JSON response:
Code:
[{"success":"true","data":{"returnCode":"0"}}]
Form Submit:
Code:
submit: function(options) {
console.log("controllers.SignOnController - signOn");
var theForm = Ext.getCmp('signOnForm');
theForm.submit({
method: 'POST',
waitMsg: {
message: 'Processing'
},
scope: this,
success: function(form, response) {
console.log("controllers.SignOnController - successful logon");
Ext.dispatch({
controller: 'Accounts',
action: 'index',
historyUrl: 'Accounts/index'
})
},
failure: function(form, response) {
Ext.Msg.alert('Login Failed: ', response.errorMessage);
}
})
console.log("Submitted form...");
}
Form:
Code:
Aries.views.SignOnForm = Ext.extend(Ext.form.FormPanel, {
scroll: 'vertical',
id: 'signOnForm',
url: proxyPrefix + '/signon',
items: [{
//add a fieldset
xtype: 'fieldset',
title: 'Authentication',
instructions: 'Please enter the your login details',
//apply the common settings to all the child items of the fieldset
defaults: {
required: true, //required field
labelAlign: 'left',
labelWidth: '40%'
},
items: [{ //add a text field
xtype: 'textfield',
name : 'username',
label: 'Username',
value: 'justin',
useClearIcon: true, //shows the clear icon in the field when user types
autoCapitalize : false
},{ //add a password field
xtype: 'passwordfield',
name : 'password',
label: 'Password',
value: 'justin',
useClearIcon: true
},
{
xtype: 'button',
text: 'Sign On',
ui: 'confirm',
width: '40%',
handler: function() {
Ext.dispatch({
controller: 'SignOn',
action: 'submit',
data: Aries.views.SignOnForm
});
},
scope: this
}
],
listeners : {
//listener if the form is submitted, successfully
submit : function(form, result){
console.log('success', Ext.toArray(arguments));
},
//listener if the form submission fails
exception : function(form, result){
console.log('failure', Ext.toArray(arguments));
}
}
}],
initComponent: function() {
Aries.views.SignOnForm.superclass.initComponent.apply(this, arguments);
}
});