1. #1
    Ext User
    Join Date
    Nov 2007
    Posts
    11
    Vote Rating
    0
    dieyoudie is on a distinguished road

      0  

    Question Form Json Submit doesn't work but the Load work

    Form Json Submit doesn't work but the Load work


    there're several thread about form submit but i check all of those but still didn't solve my problem. spent 3 days and this is as far as i got
    Code:
    // JavaScript Document
    Ext.onReady(function(){
     
     Ext.QuickTips.init();
     
        // turn on validation errors beside the field globally
        Ext.form.Field.prototype.msgTarget = 'side';
     
        var fs = new Ext.FormPanel({
            frame: true,
            id:'frmRegister',
            title:'Member Detail',
            labelAlign: 'right',
            labelWidth: 85,
            width:600,
            waitMsgTarget: true,
    errorReader : new Ext.data.JsonReader(
    {
    root:"errors",
    successProperty:"success"
    },
    ['id', 'msg']),
     
            items: [
                new Ext.form.FieldSet({
                    xtype:'fieldset',
                    title:'User Info',
                    collapsible:false,
                    autoHeight:true,
                    items:[
                        new Ext.form.TextField({
                            fieldLabel: 'User Name',
                            name: 'txtUserName',
                            width:190,
                            allowBlank:false
                        }),
                        new Ext.form.TextField({
                            fieldLabel: 'Password',
                            name: 'txtPassword',
                            width:190,
                            inputType:'password',
                            allowBlank:false
                        })
                     ]
                })
            ]
        });
     
        // explicit add
        var submit = fs.addButton({
            text: 'Submit',
            //disabled:true,
            handler: function(){     
                fs.form.submit({waitMsg:'Saving Data...',
            url:'register_process.php'});
            }
        });
         fs.render(document.body);
     
        fs.on({
            actioncomplete: function(form, action){
                alert(action.result.data[0].responseMsg);
            }
           }
        });
     
    });
    the register_process.php is just doing the echo
    {"success":true,"data":[{responseMsg:"the return message"}]}

    so when i click on submit button it just showing the waiting message "Saving Data..." and stay like that forever.
    firebug show that i receive the above json string back from the php page

    the thing is if i keep all the code above the same and then just change fs.form.submit to fs.form.load it will work and i'll get the alert prompt of "the return message" without changing any other line. so i dont know what the different in handling load and submit

  2. #2
    Ext User
    Join Date
    Nov 2007
    Posts
    11
    Vote Rating
    0
    dieyoudie is on a distinguished road

      0  

    Default


    oh i dont know if i miss the firebug error or it really wasn't there before. but now there's also the message saying that
    M has no properties
    in the extall.js

  3. #3
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854
    Vote Rating
    4
    tryanDLS is on a distinguished road

      0  

    Default


    You're specify a reader with a root that doesn't exist in your return data. Actually you don't even need a reader - the functionality is built in for JSON. See this thread for an example http://extjs.com/forum/showthread.php?t=19673

Thread Participants: 1