ajax不能跳转页面,需要传递Message来决定结果

来源:互联网 发布:淘宝店怎么改名字 编辑:程序博客网 时间:2024/05/22 15:51
@RequestMapping(value = "/updateEmployeeIntro", method = RequestMethod.POST)
@ResponseBody
public Message updateEmployeeIntroById(HttpSession session, EmployeeIntroVO employeeIntroVo) {
Message msg = new Message();
EmployeeByCodeAndPwdVO employee = (EmployeeByCodeAndPwdVO) session.getAttribute("employee");
employeeIntroVo.setEmployeeId(employee.getId());
employeeIntroVo.setUpdator(employee.getId());
employeeIntroVo.setUpdateTime(new Date());
int retNumber = employeeBaseService.updateEmployeeDetail(employeeIntroVo);
if (retNumber > 0) {
msg.setResult(true);
} else {
msg.setResult(false);
}
return msg;

}

$("#submitProcess").on("click",function(event){
   event.preventDefault();//使a自带的方法失效,即无法调整到href中的URL(http://www.baidu.com)
  
   var serialNumber=$("#serialNumber").val();
   var organizationLevelName = $("#organizationLevelName").val();
   var employeePosts = $("#employeePosts").val();
   var employeeNickName = $("#employeeNickName").val();
   var employeeCode = $("#employeeCode").val();
   var reason = $("#borrowReason").val();
   var borrowMoney = $("#borrowMoney").val(); 
   var applicationDate = $("#applicationDate").val();
   var repaymentDate = $("#repaymentDate").val();

   //前台检查
   if(reason == "" && reason==null) {
    alert("Apply Reason Can not be empty");
   }
   if(borrowMoney == 0 && borrowMoney == null) {
    alert("Apply Money Can not be empty");
   }
   if(applicationDate == null) {
    alert("applicationDate Can not be empty");
   }
   if(repaymentDate == null) {
    alert("repaymentDate Can not be empty");
   }
   
   $.ajax({
          type: "POST",
          url: basePath + "workflow/oa/costBorrow/startProcess.htmls",
          data: {
          "serialNumber":serialNumber,
          "organizationLevelName": organizationLevelName,
          "employeePosts": employeePosts,
          "employeeNickName": employeeNickName,
          "employeeCode" : employeeCode,
          "applicationDate" : applicationDate,
          "repaymentDate" : repaymentDate,
          "reason" : reason,
          "money" : borrowMoney
          
          },        
          dataType:"json",
          success: function(result){
             //请求正确之后的操作
       //      alert(result.msg);
    //     alert("sucess");
     
          if("loginAgain" == result.msg) {
          setTimeout(function(){
window.location=basePath+"admin/employee/login.htmls";
},100);
          } else {
          setTimeout(function(){
window.location=basePath+"workflow/process/start.htmls";
},100);
          }
          /* */
          },
          error: function(result){
             //请求失败之后的操作
            alert("fail");
          }
   });
});


0 0
原创粉丝点击