This article mainly introduces 4 kinds of Ajax asynchronous submitting methods commonly used in ExtJS, which can be referred to by friends in the following
/** Code is as follows: * The first type of AJAX submission * This approach requires direct use of the Ext Ajax method for submission * Using this method, you need to encapsulate the parameters to be passed * @return * / function saveuser_ajaxsubmit1 () { Ext.Ajax.request ({ url: ' user_save.action ', method: ' Post ' , params: { userName:document.getElementById (' userName ') .value, password:document.getElementById (' password ') .value }, success:function (response, Options) { var o = Ext.util.JSON.decode ( Response.responsetext); alert (o.msg); }, failure:function () { } }); } nbsp * The second type of AJAX submission * This way you will specify an HTML form for ext Ajax * Using this method, you do not need to encapsulate the parameters to be passed * * @return */ function Saveuser_ajaxsubmit2 () { Ext.Ajax.request ({ url: ' user_save.action ', method: ' Post ', Form: ' UserForm ',//Specify form success:function (response, Options) { var o = Ext.util.JSON.decode (response.respo Nsetext); alert (o.msg); }, FAilure:function () { } }); } /** * The third type of AJAX submission * This way will be submitted for Ext's own form * Use this way, you need To use ext own TextField component * * @return */ function saveuser_ajaxsubmit3 () { //define form var for Mpanel = new Ext.formpanel ({ labelwidth:75, frame:true, bodystyle: ' padding:5px 5px 0 ', Widt h:350, defaults: { width:230 }, defaulttype: ' TextField ', items: [{ Fieldlabel : ' username ', name: ' UserName ', allowblank:false }, { Fieldlabel: ' Password ', name: ' Password ' &N Bsp }] }); //Definition window var win = new Ext.window ({ title: ' Add user ', layout: ' Fit ', width:50 0, height:300, closeaction: ' Close ', closable:false, plain:true, Bsp Buttons: [{ text: ' OK ', handler:function () { var form = Formpanel.getform (); var userName = f Orm.findfield ('UserName '). GetValue (). Trim (); var password = form.findfield (' password '). GetValue (). Trim (); if (!username { alert (' User name cannot be empty '); return; } if (!password) { alert (' Password cannot be empty '); return; nbsp Form.submit ({ waittitle: ' Please later ... ', waitmsg: ' Saving user information, please later ... ', URL: ' user_save.action ', metho D: ' Post ', success:function (form, action) { alert (action.result.msg); }, (for M, action) { alert (action.result.msg); } }); } }, { text: ' Cancel ', handler:funct Ion () { win.close (); } }] }); win.show (); } /** * Fourth method of Ajax submission * Such side form to convert HTML forms to Ext forms for asynchronous submissions * Using this method, you need to define a good HTML form * * @return */ function Saveuser_ AJAXSUBMIT4 () { new Ext.form.BasicForm (' UserForm '). Submit ({ Waittitle: ' Please later ... ', waitmsg: ' Saving user information , please later ... ', URL: ' user_save.action ', &NBsp Method: ' Post ', success:function (form, action) { alert (action.result.msg); }, N (form, action) { alert (action.result.msg); } }); }