无为清净楼资源网 Design By www.qnjia.com
/**
复制代码 代码如下:
* 第一种Ajax提交方式
* 这种方式需要直接使用ext Ajax方法进行提交
* 使用这种方式,需要将待传递的参数进行封装
* @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() {
}
});
}
/**
* 第二种Ajax提交方式
* 这种方式将为ext的ajax指定一个html表单
* 使用这种方式,不需要将待传递的参数进行封装
*
* @return
*/
function saveUser_ajaxSubmit2() {
Ext.Ajax.request( {
url : 'user_save.action',
method : 'post',
form : 'userForm', // 指定表单
success : function(response, options) {
var o = Ext.util.JSON.decode(response.responseText);
alert(o.msg);
},
failure : function() {
}
});
}
/**
* 第三种Ajax提交方式
* 这种方式将为ext的自己的表单进行提交
* 使用这种方式,需要使用ext自己的textField组件
*
* @return
*/
function saveUser_ajaxSubmit3() {
// 定义表单
var formPanel = new Ext.FormPanel( {
labelWidth : 75,
frame : true,
bodyStyle : 'padding:5px 5px 0',
width : 350,
defaults : {
width : 230
},
defaultType : 'textfield',
items : [ {
fieldLabel : '用户名',
name : 'userName',
allowBlank : false
}, {
fieldLabel : '密 码',
name : 'password'
} ]
});
// 定义窗口
var win = new Ext.Window( {
title : '添加用户',
layout : 'fit',
width : 500,
height : 300,
closeAction : 'close',
closable : false,
plain : true,
items : formPanel,
buttons : [ {
text : '确定',
handler : function() {
var form = formPanel.getForm();
var userName = form.findField('userName').getValue().trim();
var password = form.findField('password').getValue().trim();
if (!userName) {
alert('用户名不能为空');
return;
}
if (!password) {
alert('密码不能为空');
return;
}
form.submit( {
waitTitle : '请稍后...',
waitMsg : '正在保存用户信息,请稍后...',
url : 'user_save.action',
method : 'post',
success : function(form, action) {
alert(action.result.msg);
},
failure : function(form, action) {
alert(action.result.msg);
}
});
}
}, {
text : '取消',
handler : function() {
win.close();
}
} ]
});
win.show();
}
/**
* 第四种Ajax提交方式
* 这种方式将html的表单转化为ext的表单进行异步提交
* 使用这种方式,需要定义好html的表单
*
* @return
*/
function saveUser_ajaxSubmit4() {
new Ext.form.BasicForm('userForm').submit( {
waitTitle : '请稍后...',
waitMsg : '正在保存用户信息,请稍后...',
url : 'user_save.action',
method : 'post',
success : function(form, action) {
alert(action.result.msg);
},
failure : function(form, action) {
alert(action.result.msg);
}
});
}
复制代码 代码如下:
* 第一种Ajax提交方式
* 这种方式需要直接使用ext Ajax方法进行提交
* 使用这种方式,需要将待传递的参数进行封装
* @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() {
}
});
}
/**
* 第二种Ajax提交方式
* 这种方式将为ext的ajax指定一个html表单
* 使用这种方式,不需要将待传递的参数进行封装
*
* @return
*/
function saveUser_ajaxSubmit2() {
Ext.Ajax.request( {
url : 'user_save.action',
method : 'post',
form : 'userForm', // 指定表单
success : function(response, options) {
var o = Ext.util.JSON.decode(response.responseText);
alert(o.msg);
},
failure : function() {
}
});
}
/**
* 第三种Ajax提交方式
* 这种方式将为ext的自己的表单进行提交
* 使用这种方式,需要使用ext自己的textField组件
*
* @return
*/
function saveUser_ajaxSubmit3() {
// 定义表单
var formPanel = new Ext.FormPanel( {
labelWidth : 75,
frame : true,
bodyStyle : 'padding:5px 5px 0',
width : 350,
defaults : {
width : 230
},
defaultType : 'textfield',
items : [ {
fieldLabel : '用户名',
name : 'userName',
allowBlank : false
}, {
fieldLabel : '密 码',
name : 'password'
} ]
});
// 定义窗口
var win = new Ext.Window( {
title : '添加用户',
layout : 'fit',
width : 500,
height : 300,
closeAction : 'close',
closable : false,
plain : true,
items : formPanel,
buttons : [ {
text : '确定',
handler : function() {
var form = formPanel.getForm();
var userName = form.findField('userName').getValue().trim();
var password = form.findField('password').getValue().trim();
if (!userName) {
alert('用户名不能为空');
return;
}
if (!password) {
alert('密码不能为空');
return;
}
form.submit( {
waitTitle : '请稍后...',
waitMsg : '正在保存用户信息,请稍后...',
url : 'user_save.action',
method : 'post',
success : function(form, action) {
alert(action.result.msg);
},
failure : function(form, action) {
alert(action.result.msg);
}
});
}
}, {
text : '取消',
handler : function() {
win.close();
}
} ]
});
win.show();
}
/**
* 第四种Ajax提交方式
* 这种方式将html的表单转化为ext的表单进行异步提交
* 使用这种方式,需要定义好html的表单
*
* @return
*/
function saveUser_ajaxSubmit4() {
new Ext.form.BasicForm('userForm').submit( {
waitTitle : '请稍后...',
waitMsg : '正在保存用户信息,请稍后...',
url : 'user_save.action',
method : 'post',
success : function(form, action) {
alert(action.result.msg);
},
failure : function(form, action) {
alert(action.result.msg);
}
});
}
标签:
extJS,Ajax,异步提交
无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com
暂无评论...
更新日志
2024年10月04日
2024年10月04日
- 群星《前途海量 电影原声专辑》[FLAC/分轨][227.78MB]
- 张信哲.1992-知道新曲与精丫巨石】【WAV+CUE】
- 王翠玲.1995-ANGEL【新艺宝】【WAV+CUE】
- 景冈山.1996-我的眼里只有你【大地唱片】【WAV+CUE】
- 群星《八戒 电影原声带》[320K/MP3][188.97MB]
- 群星《我的阿勒泰 影视原声带》[320K/MP3][139.47MB]
- 纪钧瀚《胎教古典音乐 钢琴与大提琴的沉浸时光》[320K/MP3][148.91MB]
- 刘雅丽.2001-丽花皇后·EMI精选王【EMI百代】【FLAC分轨】
- 齐秦.1994-黄金十年1981-1990CHINA.TOUR.LIVE精丫上华】【WAV+CUE】
- 群星.2008-本色·百代音乐人创作专辑【EMI百代】【WAV+CUE】
- 群星.2001-同步过冬AVCD【环球】【WAV+CUE】
- 群星.2020-同步过冬2020冀待晴空【环球】【WAV+CUE】
- 沈雁.1986-四季(2012梦田复刻版)【白云唱片】【WAV+CUE】
- 纪钧瀚《胎教古典音乐 钢琴与大提琴的沉浸时光》[FLAC/分轨][257.88MB]
- 《国语老歌 怀旧篇 3CD》[WAV/分轨][1.6GB]