Results 1 to 2 of 2

Thread: Is there any way to get a FormPanel to submit JSON?

  1. #1
    Ext User
    Join Date
    Jan 2010
    Posts
    26
    Vote Rating
    0
      0  

    Default Is there any way to get a FormPanel to submit JSON?

    By default, a FormPanel submits data as application/x-www-form-urlencoded. Is there any way to get it to submit JSON instead?

  2. #2
    Ext User
    Join Date
    Oct 2008
    Location
    Norway
    Posts
    106
    Vote Rating
    0
      0  

    Default

    Something like this?

    Code:
    new Ext.Window({
      title: 'jsontest',
      width: 400,
      height: 400,
      closable: true,
      items: [{
        xtype: 'form',
        id: 'myFormPanel',
        defaultType: 'textfield',
        items: [{name: 'value1'},{name: 'value2'}]
      }],
      buttons: [{
        text: 'submit',
        handler: function(){
          var f = Ext.getCmp('myFormPanel').getForm();
          Ext.Ajax.request({
             url: 'submithandler.php',
             headers: {'Content-Type':'application/json; charset=utf-8'},
             params: Ext.util.JSON.encode(f.getValues());
          });
        }
      }]
    }).show();

Posting Permissions

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