There is a small difference between an ExtJS4 button form submission request and a direct ajax request.

Source: Internet
Author: User

In today's coding process, I found that there is a slight difference in the return value between the request submitted by the button and the direct ajax request.

View direct ajax

Ext.Ajax.request({url : "../UserSelectAllServlet",method : 'POST',success : function(response) {var json = Ext.JSON.decode(response.responseText);   //column = new Ext.grid.column.Column(json.columModle);//alert(json.data[2].id);var store = Ext.create('Ext.data.Store', {fields : json.fields,data : json.data});Ext.getCmp("grid_a").reconfigure(store, json.columns);}});

This code requests the servlet to obtain the returned value as a json string, which must be transcoded into a json object using ext. json. decode. The following code can operate on this json object:


Let's look at the form submission request of the button.



Form. submit ({success: function (form, action) {// Ext. msg. alert ('success', action. result. msg); // console. log (action. result. log); var json = action. result. log; // column = new Ext. grid. column. column (json. columModle); // alert (json. data [2]. id); var store = Ext. create ('ext. data. store', {fields: json. fields, data: json. data}); Ext. getCmp ("grid_a "). reconfigure (store, json. columns); // Ext. getCmp ("grid "). render (); grid_a.show ();}/*, failure: function (form, action) {Ext. msg. alert ('failed', "Failed ");}*/});

This code is a form submission request. The object obtained using action. result does not need to be converted to json format again ..


I just learned extjs .. If your understanding is incorrect, please point it out directly ..

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.