Question

By default, a FormPanel in ExtJS 3.1.0 posts the form fields as application/x-www-form-urlencoded when you call its submit() function.

Is there any way to get it to post JSON instead?

Was it helpful?

Solution

You can use getValues() to pull the values and then Ext.encode() them and manually do an Ext.Ajax.request({}) with this data as well.

OTHER TIPS

You probably want to extend Ext.form.Action.Submit to encode the params as JSON instead of url-encoding them in the body.

You can override Ext.form.Action.Submit.run.

Just like this:

Ext.override(Ext.form.Action.Submit, {
    run: function() {
        // Your code here
    }
});

Just put in params

var formData = App.formPanel.getValues(false);
Ext.net.DirectMethod.request({ 
     url: '/Product/Save',
     params: formData,
     success: function(jsonResult){
     }
});

or

App.formPanel.submit();

Before set a App.formPanel.url = '/Product/Save'

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top