ajax使用

 /** 删除员工绑定点击事件 */
            $("#delete").click(function(){
                /** 获取到用户选中的复选框  */
                var checkedBoxs = boxs.filter(":checked");
                if(checkedBoxs.length < 1){
                    $.ligerDialog.error("请选择一个需要删除的部门!");
                }else{
                    /** 得到用户选中的所有的需要删除的ids */
                    var ids = checkedBoxs.map(function(){
                        return this.value;
                    })
                    
                    $.ligerDialog.confirm("确认要删除吗?","删除部门",function(r){
                        if(r){
                            // alert("删除:"+ids.get());
                            // 发送请求
                            //window.location = "${pageContext.request.contextPath}/dept/removeDept?ids=" + ids.get();
                           $.get("${pageContext.request.contextPath}/dept/removeDept.do?ids="+ids.get(),
                               function (data) {
                                       if (data == "OK"){
                                           alert("部门删除成功!");
                                           window.location.href = "${pageContext.request.contextPath}/dept/findDept.do";
                                    } else if (data == "FAIL") {
                                        alert("部门删除失败!");
                                        window.location.reload();
                                    } else if(data == "ERROR"){
                                        alert("该部门存在员工,不能删除!");
                                        window.location.reload();
                                    }else {
                                        alert("内部服务器异常!");
                                        window.location.reload();
                                    }
                           });


                        }
                    });
                }
            })
原文地址:https://www.cnblogs.com/mm163/p/11056023.html