JSP部分:
<a class="easyui-linkbutton" iconCls="icon-cut" plain="true" onclick="deleteItem()">删除</a>
<table id="rt" class="easyui-datagrid" title="保险员查询" style="height:450px" toolbar="#tb" singleSelect="false" >
<thead>
<tr>
<th data-options="field:'id',width:50,align:'center'" checkbox="true"></th>
<th data-options="field:'companyNo',width:100,align:'center'">保险公司编号</th>
<th data-options="field:'companyName',width:250,align:'center'">保险公司</th>
<th data-options="field:'operId',width:150,align:'center'">保险员号</th>
<th data-options="field:'operName',width:150,align:'center'">保险员姓名</th>
<th data-options="field:'validStat',width:100,align:'center'">有效状态</th>
<th data-options="field:'brchName',width:300,align:'center'">绑定网点名称</th>
<th data-options="field:'brchNo',width:100,align:'center'">绑定网点号</th>
</tr>
</thead>
</table>
js部分:
function deleteItem(){
var rows = $('#rt').datagrid('getSelected');
if (null == rows || rows.length == 0) {
$.messager.alert("操作提示", "请选择所要删除的记录!","info");
return;
}
$.messager.confirm('提示', '确定删除保险员绑定关系吗?', function(r){
System.out.println("-----我的标记1-----");
if(r){
var index = $('#rt').datagrid('getRowIndex', rows);
System.out.println("-----我的标记-----");
var companyNoS = {};
var operIdS = {};
var brchNoS = {};
for(var i = 0;i<rows.length;i++){
companyNoS=document.getElements("companyNo")[i];
operIdS=document.getElements("operId")[i];
brchNoS=document.getElements("brchNo")[i];
}
System.out.println("-----我的标记-----"+companyNoS);
DeleteSubmit(companyNoS,operIdS,brchNoS,rows.length,index);
}
}
);
}
function DeleteSubmit(companyNoS,operIdS,brchNoS,length,index) {//调后台方法
$.ajax({
type : "POST",
url : "/servlet/vehicleInsurance/scopeDelS?companyNoS="+companyNoS+"&operIdS="+operIdS+"&brchNoS="+brchNoS+"&length="+length,
cache : false,
success: function (data) {
data = $.trim(data); //去掉前后空格
if("true"==data){
$('#rt').datagrid('deleteRow', index);
$.messager.alert("操作提示", "保险员解绑成功!","info");
}else if("false"==data){
$.messager.alert("操作提示", "保险员解绑失败!","info");
$('#rt').datagrid('unselectRow',index);
}
},
error: function (data) {
data = $.trim(data); //去掉前后空格
$.messager.alert("操作提示", data,"info");
}
});
return false;
}
action部分:
String[] companyNoS = request.getParameterValues("companyNoS");
String[] operNoS = request.getParameterValues("operIdS");
String[] brchNoS = request.getParameterValues("brchNoS");
List companyNo = new ArrayList();
List operNo = new ArrayList();
List brchNo = new ArrayList();
String length = request.getParameter("length");
int L=Integer.parseInt(length);
try {
for(int m=0;m<L;m++){
companyNo = java.util.Arrays.asList(companyNoS);
operNo = java.util.Arrays.asList(operNoS);
brchNo = java.util.Arrays.asList(brchNoS);
String sql="update T32_VI_SCOPE set valid_stat='0' where company_no='"+companyNo+"' and oper_id='"+operNo+"' and brch_no='"+brchNo+"'";
System.out.println(sql);
int i=0;
i=access.update(sql);
if(i==0)
{
access.rollback();
access.disconnect();
/* session.setAttribute("errorMsg", "保险员解绑失败!</br>");
session.setAttribute("stepBack", "1");
response.sendRedirect("/ErrorMsg.jsp");
return;*/
flag="0";//0 失败 1成功
}
else{
access.commit();
access.disconnect();
/*session.setAttribute("successMsg","保险员解绑成功!<br>");
session.setAttribute("nextPage","/vehicleInsurance/comScopeQuery.jsp");
response.sendRedirect("/SuccessMsg.jsp");
return;*/
flag="1";//0 失败 1成功
}
}
} catch (SQLException e) {
flag="0";//0 失败
access.disconnect();
System.out.println("---SQLException----------"+e);
/*session.setAttribute("errorMsg", "数据库异常!</br>");
session.setAttribute("stepBack", "1");
response.sendRedirect("/ErrorMsg.jsp");
return;*/
}
System.out.println("------flag-------"+flag);
try {
PrintWriter out = response.getWriter();
if(flag.equals("1")){
out.print(true);
}else{
out.print(false);
}
out.flush();
out.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("---IOException----------"+e);
}
}
点击删除,操作不成功,后台也不报错,估计是js部分出错,但我不知道错哪儿.求指点,急
你要打印消息用console.log或者alert
先看下action接收到得参数对不对,确认下是哪里的问题
js怎么会有 System.out.println("-----我的标记-----");<spanstyle="color:#E53333;">我用<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:normal;background-color:#FFFFFF;color:#E53333;">alert弹框了,没有弹出来,不知道什么错了。。
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:normal;background-color:#FFFFFF;"><spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;">functiondeleteItem(){
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> varrows=$('#rt').datagrid('getSelected');
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> if(null==rows||rows.length==0){
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> $.messager.alert("操作提示","请选择所要删除的记录!","info");
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> return;
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> }
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> $.messager.confirm('提示','确定删除保险员绑定关系吗?',function(r){
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> if(r){
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> varindex=$('#rt').datagrid('getRowIndex',rows);
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> <spanstyle="color:#E53333;">alert("-----我的标记-----");
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> varcompanyNoS={};
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> varoperIdS={};
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> varbrchNoS={};
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> for(vari=0;i<rows.length;i++){
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> companyNoS=document.getElements("companyNo")[i];
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> operIdS=document.getElements("operId")[i];
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> brchNoS=document.getElements("brchNo")[i];
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> }
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> System.out.println(<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;">"-----我的标记-----"+<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;">companyNoS);
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> DeleteSubmit(companyNoS,operIdS,brchNoS,rows.length,index);
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> }
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> }
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> );
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> }
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> functionDeleteSubmit(companyNoS,operIdS,brchNoS,length,index) {//调后台方法
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> $.ajax({
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> type:"POST",
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> url :"/servlet/vehicleInsurance/scopeDelS?companyNoS="+companyNoS+"&operIdS="+operIdS+"&brchNoS="+brchNoS+"&length="+length,
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> cache:false,
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> success:function(data){
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> data=$.trim(data);//去掉前后空格
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> if("true"==data){
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> $('#rt').datagrid('deleteRow',index);
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> $.messager.alert("操作提示","保险员解绑成功!","info");
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> }elseif("false"==data){
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> $.messager.alert("操作提示","保险员解绑失败!","info");
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> $('#rt').datagrid('unselectRow',index);
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> }
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> },
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> error:function(data){
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> data=$.trim(data);//去掉前后空格
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> $.messager.alert("操作提示",data,"info");
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> }
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> });
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> returnfalse;
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;">
<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"> }
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。