Ext.Ajax.request与form.getForm().submit的区别

来源:互联网 发布:淘宝子账号没有二维码 编辑:程序博客网 时间:2024/06/04 18:33
  1. function formSubmit(){   
  2.    if (form.getForm().isValid()) { //验证表单填写的数据是否有效   
  3.     form.getForm().submit({     //调用basicForm的submit方法   
  4.      waitTitle : '提示',//标题   
  5.      waitMsg : '正在提交数据请稍后...',//提示信息   
  6.      url : 'eidtBooktype.action',   //将要把表单发送到哪里   
  7.      method : 'post',   //指定发送方式   
  8.      params : 'booktype', //携带的参数   
  9.      success : function(form, action){  //form指这个表单 action指返回内容   
  10.       var flag=action.result.msg;   
  11.       window.returnValue='SUCC';   
  12.       Ext.Msg.alert('提示',flag,function(){   
  13.        window.close();   
  14.       });   
  15.      },   
  16.      failure : function(form,action) {   
  17.       var flag=action.result.msg;   
  18.       Ext.Msg.alert('操作', flag);   
  19.      }   
  20.     });   
  21.    }   
  22. }  

 

  1. <PRE class=Ext.Ajax.request name="code">Ext.Ajax.request({   
  2.          url : 'deleteBooktypes.action',   
  3.         method : 'post',   
  4.         params : {delids:deleteids.toString()},   
  5.         success : function(form,action) {   
  6.          var respText = Ext.util.JSON.decode(form.responseText); //把字符串变为json格式   
  7.          var msg=respText.msg; //获取里面的值的方法与上面稍有不同   
  8.          Ext.MessageBox.alert('提示',msg,function(){   
  9.           bookTypeStore.reload();   
  10.          });   
  11.         },   
  12.         failure : function(response,options) {   
  13.          var respText = Ext.util.JSON.decode(response.responseText); //吧字符串变为json格式   
  14.          var msg=respText.msg;   
  15.          Ext.MessageBox.alert('提示',msg,function(){   
  16.           bookTypeStore.reload();   
  17.          });   
  18.         }   
  19.        });   
  20.  </PRE>   
  21. <P style="FONT-FAMILY: Simsun; WHITE-SPACE: normal; FONT-SIZE: medium"> </P>  

 

最明显就是success和failure时候function的参数

Ext.Ajax.request的function(response,options),option非常有用,用response.responseText获得返回参数,注意这个地方的response参数可以换成action

form.getForm().submit的function(form, action),action很有用,用action.result.msg获得返回值

还有个最明显区别是Ext.Ajax.request不可以用waitMsg