java 功能启用与禁用
时间:2021-11-10 作者:匿名
js 部分
<script type="text/javascript"> /** * 更新状态 */ function update(nid, sta, th,type){ if(type==1){ if(域名irm("是否删除?")){ } else{ return ""; } } $.ajax({ url:"/yq1012/域名",//后台url data:{ newsId:nid, status:sta }, async:false, success:function(data){ //执行成功 if(域名==1){ if(sta==9){ $("#tr_"+nid).remove(); }else if(sta==1){ $(th).attr("onclick", "update("+nid+", 0, this);").html("禁用"); }else if(sta==0){ $(th).attr("onclick", "update("+nid+", 1, this);").html("启用"); } //执行失败 }else{ alert("操作失败,请稍后重试"); } }, error:function(){ alert("网络连接失败,请稍后重试"); } }); }
页面部分
<c:if test="${item[1].status==1}"> <a href="javascript:void(0);" onclick="update(${item[1].newsId }, 0, this,2);" class="btn btn-mini">禁用</a> </c:if> <c:if test="${item[1].status==0}"> <a href="javascript:void(0);" onclick="update(${item[1].newsId }, 1, this,2);" class="btn btn-mini">启用</a> </c:if>