81,094
社区成员
发帖
与我相关
我的任务
分享
function update(){
//这里直接根据它们的id取值,得到值后然后将值通过data传到后台
var id = document.getElementById("id").value;
var username = document.getElementById("username").value;
var stuid = document.getElementById("stuid").value;
var phone = document.getElementById("phone").value;
var address = document.getElementById("address").value;
var email = document.getElementById("email").value;
$.ajax({
url: "student!change.action",
type: "post",
data: ({"id":id,"username":username,"stuid":stuid,"phone":phone,"address":address,"email":email}),//这里就是你要传的值,这里要注意写法
cache: false,
beforeSend: function(result) {
},
success: function(result) {
alert("更新成功!");
$('#dialog-overlay, #dialog-box').hide();
},
error: function(result, status) {
if (status == 'error') {
alert("系统发生错误");
}
}
});
}
function update(){
$.ajax({
url: "student!update.action",
type: "post",
data: {
//在这里加入你保存的参数值
username:"",
password:""
},
cache: false,
beforeSend: function(result) {
},
success: function(result) {
alert("成功!");
$('#dialog-overlay, #dialog-box').hide();
},
error: function(result, status) {
if (status == 'error') {
alert("系统发生错误");
}
}
});
}
items:[
{x:0,y:5,xtype:'label',text:'昵称:'},
{x:60,y:0,name: 'username',width:'130' },
{x:230,y:5,xtype:'label',text:'姓名:'},
{x:290,y:0,name: '_name',width:'130'},
{x:0,y:35,xtype:'label',text: '密码:'},
{x:60,y:30,name:'_password',width:'130'},
{x:230,y:35,xtype: 'label',text: '重复密码:'},
{x:290,y:30,name:'doublePass',width:'130'},
buttons:[{
text:'Send',
handler:function(){
if(perform.form.isValid()){
perform.form.submit({
url:'/Extjs_Center/personnelAction.do?method=addPersonnel',
method:'post',
success: function(form,action){
if(action.result.msg=='succ'){
document.location='../../jsp/personnel/personnelList.jsp';
}else{
Ext.Msg.alert('false','员工创建失败!');
}
},
failure: function(form,action){
Ext.Msg.alert('错误','服务器出现错误请稍后再试!');
}
});
}
}
},{
text: 'Cancel'
}]
public ActionForward addPersonnel(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
PersonnelForm frm = (PersonnelForm) form;
System.out.println(frm.getUsername()+" "+frm.get_password());
PersonnelBo pbo = new PersonnelBo();
pbo.AddPersonnel(response, frm);
return null;
}
function queryById(id){
$.ajax({
url: "student!queryById.action",
type: "post",
data:({id:id}),
cache: false,
beforeSend: function(result) {
},
success: function(json) {
var student = json.student;
var html = '<form><table border="1" cellpadding="0" cellspacing="0">';
html+='<tr><td>编号</td><td><input type="text" disabled="true" id="id" value="'+student.id+'"/></td></tr>'
html+='<tr><td>用户名</td><td><input type="text" id="username" value="'+student.username+'"/></td></tr>';
html+='<tr><td>学生号</td><td><input type="text" id="stuid" value="'+student.stuid+'"/></td></tr>';
html+='<tr><td>电话</td><td><input type="text" id="phone" value="'+student.phone+'"/></td></tr>';
html+='<tr><td>地址</td><td><input type="text" id="address" value="'+student.address+'"/></td></tr>';
html+='<tr><td>邮箱</td><td><input type="text" id="email" value="'+student.email+'"/></td></tr>';
html+='</table></form>';
var maskHeight = $(document).height();
var maskWidth = $(window).width();
var dialogTop = ((maskHeight) - ($('#dialog-box').height()))/2-100;
var dialogLeft = ((maskWidth) - ($('#dialog-box').width()))/2;
$('#dialog-overlay').css({height:maskHeight, width:maskWidth}).show();
$('#dialog-box').css({top:dialogTop, left:dialogLeft}).show();
$('#dialog-message').html(html);
},
error: function(result, status) {
if (status == 'error') {
alert("系统发生错误");
}
}
});
}
function update(){
$.ajax({
url: "student!update.action",
type: "post",
data: null,
cache: false,
beforeSend: function(result) {
},
success: function(result) {
alert("成功!");
$('#dialog-overlay, #dialog-box').hide();
},
error: function(result, status) {
if (status == 'error') {
alert("系统发生错误");
}
}
});
}