How can I get a FormPanel for POST JSON using ExtJS 3.1.0?

By default, a FormPanelin ExtJS 3.1.0 places form fields as application/x-www-form-urlencodedwhen you call the submit () function.

Is there any way to get it to publish JSON?

+3
source share
4 answers

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

+3
source

You probably want to expand Ext.form.Action.Submitto encode parameters as JSON, rather than encode them in the body.

+2
source

Ext.form.Action.Submit.run.

:

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

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

App.formPanel.submit();

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

0
source

Source: https://habr.com/ru/post/1731362/


All Articles