为什么前台ajax调用后台的方法后,会自动刷新页面,我想不刷新页面,怎么写?
6 回复
真的会刷新页面,这样写有问题么
//前台的代码
$('#save').click(function(){
$.ajax({
type: "POST",
url:'${base}/dept/edit',
data:$('#deptForm').serialize(),
async: false,
error: function(request) {
swal({
title: "糟糕",
text: "连接出错!",
type: "fail"
});
},
success: function(data) {
if(data.data=="success"){
swal({
title: "太帅了",
text: "添加部门成功了!",
type: "success"
});
}
}
});
});
//后台
@At("/edit")
@Ok("json")
public Object edit(@Param("..")Dept dept) {
String result = "";
if(dept.getId().equals("new")){
dept.setId(UuidUtil.getUUID());
dept.setAddTime(new Date());
dept.setAddUser("admin");
deptService.add(dept);
result = "success";
}else {
dept.setUpdateTime(new Date());
dept.setUpdateUser("admin");
deptService.update(dept);
result = "success";
}
return new NutMap().setv("ok", result);
}
添加回复
请先登陆