PDA

View Full Version : [RESOLVED] Success / failure callbacks not triggered



mglaser
2 Aug 2009, 6:39 PM
Hi, with Ext 3.0 the form post response seems to go into a void and does not trigger the call back events. If I use Ext 2.2 instead with the same code the events are triggered.

Here is my form code:


var regform = new Ext.form.FormPanel({
id: 'newaccountform',
labelWidth: 125,
frame: true,
title: 'Create a new account',
bodyStyle: 'padding:5px 5px 0',
width: 350,
defaults: {
width: 230
},
defaultType: 'textfield',
items: [{
fieldLabel: 'First Name',
name: 'firstname',
allowBlank: false
}, {
fieldLabel: 'Last Name',
name: 'lastname',
allowBlank: false
}, {
fieldLabel: 'Company',
name: 'company'
}, {
fieldLabel: 'Contact Phone',
name: 'phone',
allowBlank: false
}, {
fieldLabel: 'Email Address',
name: 'email',
vtype: 'email'
}, {
id: 'txtUsername',
fieldLabel: 'Username',
name: 'username',
allowBlank: false
}, {
fieldLabel: 'Password',
inputType: "password",
name: 'password'
}],

buttons: [{
text: 'Create Account',
handler: function(){
if (regform.getForm().isValid()) {
regform.getForm().submit({
url: '/content.asp',
params: {
syscmd: 'control',
mod: 'customer',
task: 'MakeSite'
},
waitMsg: 'Submitting your data...',
success: function(form, action){
// server responded with success = true
var result = action.result;
Ext.Msg.alert('Success','It Worked');
},
failure: function(form, action){
if (action.failureType === Ext.form.Action.CONNECT_FAILURE) {
Ext.Msg.alert('Error', 'Status:' + action.response.status + ': ' +
action.response.statusText);
}
if (action.failureType === Ext.form.Action.SERVER_INVALID) {
// server responded with success = false
Ext.Msg.alert('Invalid', action.result.errormsg);
}
}
});
}
}
}, {
text: 'Cancel'
}]
});

On submit, the server returns a text/plain (have also tried HTML and JS response types) response:



{ "success":false, "message": "Please correct the fields marked in red.", "errors": { "txtUsername": "Username already exists."} }
It doesn't matter if the call succeeds or fails, the loading indicator doesn't go away but the data comes back from the server with a 200 response.

Can anyone please help me with this?

Thank you,
Mike

mglaser
3 Aug 2009, 2:15 AM
I've cut the form down to a bare minimum and it's starting to look like a bug in Ext to me. Am I missing something? Here is the bare form:



var regform = new Ext.form.FormPanel({
url: '/wtc/server/formtest.asp',
method: 'post',

defaultType: 'textfield',
items: [{
id: 'name',
fieldLabel: 'Name',
name: 'name'
}],

buttons: [{
text: 'Create Account',
handler: function(){
regform.getForm().submit({
waitMsg: 'Submitting your data...',
success: function(form, action){
// server responded with success = true
var result = action.result;
Ext.Msg.alert('Success','It Worked');
},
failure: function(form, action){
if (action.failureType === Ext.form.Action.CONNECT_FAILURE) {
Ext.Msg.alert('Error', 'Status:' + action.response.status + ': ' +
action.response.statusText);
}
if (action.failureType === Ext.form.Action.SERVER_INVALID) {
// server responded with success = false
Ext.Msg.alert('Invalid', action.result.errormsg);
}
}
});
}

}]
});
Here is the server side code:


response.ContentType = "text/html" ' also tried text/plain
response.write " { success:true }"
The form never comes back from the submit, and like I pointed out earlier if I replace Ext 3.0 with Ext 2.2 everything works wonderfully. I would appreciate any pointers as to what I might be doing wrong.

Thank you,
Mike

Animal
3 Aug 2009, 2:52 AM
Should be the work of 10 minutes to debug this. You have full source code and a good debugger.

mglaser
3 Aug 2009, 2:59 AM
Thank you for your response, I've just figured out it was me linking in an Ext 2.2 user extension that was breaking the submit process. I'm sorry for wasting your and other's time. :(

If possible please mark as resolved.

Regards,
Mike

Animal
3 Aug 2009, 3:41 AM
Can you post a message to the Ext 3 upgrade thread.

I think there should be a section in the header of that about which UXs from 2.0 will break when run under 3.0.