JQuery使用$.ajax和checkbox實現(xiàn)下次不在通知功能
XXX平臺要實現(xiàn)一個功能,公告彈出頁面上使用復(fù)選框設(shè)置不再通知此類公告。
原理:<input type="checkbox" id="isSelect" name="isSelect" value="10" onclick="javascript:noTips();"/>,checkbox選中后提交表單,那么struts2的Action中isSelect就為'10',不選中提交表單isSelect為null。
1.jsp頁面
<form id="form1">
<div class="jf_tanchu">
<div class="jf_tanchutit">${ bussinessNotice.noticeTitle}</div>
<div class="jf_tanchubox">
<div class="jf_tanchubox_right">
公告類型:<v:dcolor code="${ bussinessNotice.noticeType}"/>
發(fā)布時間:<fmt:formatDate value="${ bussinessNotice.createDate}" pattern="yyyy-MM-dd"/>
</div>
${bussinessNotice.noticeInfo}
</div>
</div>
<s:if test="bussinessNotice.noticeType=='25'||bussinessNotice.noticeType=='63'||bussinessNotice.noticeType=='64'">
<div>
<input type="hidden" name="noticeType" value="${bussinessNotice.noticeType}"/>
<input type="checkbox" id="isSelect" name="isSelect" value="${bussinessNotice.noticeType}" onclick="javascript:noTips();"/>
<label for="isSelect">不再通知此類公告</label>
</div>
</s:if>
</form>
2.js代碼
function noTips(){
var formParam = $("#form1").serialize();//序列化表格內(nèi)容為字符串
$.ajax({
type:'post',
url:'Notice_noTipsNotice',
data:formParam,
cache:false,
dataType:'json',
success:function(data){
}
});
}
3.NoticeAction代碼
/**
* checkbox不提示公告,需要修改TBussinessSet中的屏蔽狀態(tài),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());
}
}
相關(guān)文章
jQuery插件ajaxfileupload.js實現(xiàn)上傳文件
這篇文章主要為大家詳細(xì)介紹了jQuery插件ajaxfileupload.js實現(xiàn)上傳文件的相關(guān)資料,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2016-05-05
jquery UI Datepicker時間控件沖突問題解決
這篇文章主要介紹了jquery UI Datepicker時間控件沖突問題的解決,具有一定的參考價值,感興趣的小伙伴們可以參考一下2016-12-12
JQuery實現(xiàn)網(wǎng)頁右側(cè)隨動廣告特效
本文給大家分享的是2則使用jquery實現(xiàn)網(wǎng)頁右側(cè)隨動廣告特效的代碼,非常的簡單實用,有需要的小伙伴可以參考下。2016-01-01

