Home > Web Front-end > JS Tutorial > body text

JQuery使用$.ajax和checkbox实现下次不在通知功能_jquery

WBOY
Release: 2016-05-16 16:03:45
Original
1193 people have browsed it

XXX平台要实现一个功能,公告弹出页面上使用复选框设置不再通知此类公告。
 
原理:,checkbox选中后提交表单,那么struts2的Action中isSelect就为'10',不选中提交表单isSelect为null。
 
1.jsp页面

${ bussinessNotice.noticeTitle}
公告类型: 发布时间:
${bussinessNotice.noticeInfo}
Copy after login

2.js代码

 function noTips(){ 
  var formParam = $("#form1").serialize();//序列化表格内容为字符串 
  $.ajax({ 
    type:'post',   
    url:'Notice_noTipsNotice', 
    data:formParam, 
    cache:false, 
    dataType:'json', 
    success:function(data){ 
    } 
  }); 
} 
 
Copy after login

3.NoticeAction代码

/** 
 * checkbox不提示公告,需要修改TBussinessSet中的屏蔽状态,ajax异步请求 
 */ 
public void noTipsNotice(){ 
  try { 
    PrintWriter out = this.getResponse().getWriter(); 
     
    bussinessSet = BussinessSetService.queryById(getUserId()); 
    String state = ""; 
    if(isSelect==null){//noticeType==null没有选中checkbox 
      state = "11"; 
    } 
    else{ 
      state = "10"; 
    } 
    if("25".equals(noticeType)){ 
      bussinessSet.setSaleBack(state); 
    } 
    else if("63".equals(noticeType)){ 
      bussinessSet.setRemittanceBank(state); 
    } 
    else if("64".equals(noticeType)){ 
      bussinessSet.setRemittanceOnline(state); 
    } 
    BussinessSetService.update(bussinessSet); 
     
    out.print(""); 
  } catch (Exception e) { 
    log.error(e.fillInStackTrace()); 
  } 
} 
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!