1. #1
    Sencha User
    Join Date
    Nov 2011
    Posts
    20
    Vote Rating
    0
    simonr26 is on a distinguished road

      0  

    Question Unanswered: How carry out form submission using JSON, Ajax?

    Unanswered: How carry out form submission using JSON, Ajax?


    Hello,
    Please can you specify how to carry out form submission using Ajax, JSON


    I have a form with a submit handler as shown below. Ths sends data to
    server using Ajax but not JSON.
    Please can you inform me how this can be done - preferably using a not
    too complicated mechanism.


    Code:
    handler: function() {
        var form = this.up('form').getForm(); // get the basic form
        if (form.isValid()) { // make sure the form contains valid data before submitting
            form.submit({
    		url:'/dest/frm',
                   success: function(form, action) {
                    Ext.Msg.alert('Success', action.result.msg);
                },
                failure: function(form, action) {
                    Ext.Msg.alert('Failed', action.result.msg);
                }
            });
        } else { // display error alert if the data is invalid
            Ext.Msg.alert('Invalid Data', 'Please correct form errors.')
        }
    }



    kind regards,
    Simon

  2. #2
    Sencha Premium Member tobiu's Avatar
    Join Date
    May 2007
    Location
    Munich (Germany)
    Posts
    2,695
    Vote Rating
    114
    Answers
    130
    tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all

      0  

    Default


    the default implementation of forms is not meant to wrap the params into a JSON string.

    You can call form.getValues() instead submitting it and use a normal ext.ajax call and format the values to your needs using ext.encode or whatever.
    Best regards
    Tobias Uhlig
    __________

    S-CIRCLES Social Network Engine

Thread Participants: 1