Results 1 to 5 of 5

Thread: [RESOLVED] Success / failure callbacks not triggered

  1. #1

    Smile [RESOLVED] Success / failure callbacks not triggered

    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:
    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:

    Code:
    { "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
    Last edited by mglaser; 3 Aug 2009 at 3:38 AM. Reason: Found problem

  2. #2

    Question Minimal test case

    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:

    Code:
    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:
    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

  3. #3
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    Should be the work of 10 minutes to debug this. You have full source code and a good debugger.

  4. #4

    Default Apologies

    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

  5. #5
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •