JQuery uses $. ajax and checkbox to implement the function of not notifying users next time. jquery. ajax
To implement a function on the XXX platform, use the check box settings on the announcement pop-up page to no longer notify such announcements.
Principle: <input type = "checkbox" id = "isSelect" name = "isSelect" value = "10" onclick = "javascript: noTips ();"/>, when the checkbox option is selected and the form is submitted, the isSelect value in the struts2 Action is '10', And the isSelect value in the unselected submission form is null.
1. jsp page
<Form id = "form1"> <div class = "jf_tanchu"> <div class = "jf_tanchutit" >$ {bussinessNotice. noticeTitle} </div> <div class = "jf_tanchubox"> <div class = "jf_tanchubox_right"> announcement type: <v: dcolor code = "$ {bussinessNotice. noticeType} "/> Release Date: <fmt: formatDate value =" $ {bussinessNotice. createDate} "pattern =" yyyy-MM-dd "/> </div >$ {bussinessNotice. noticeInfo }</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 "> no longer notice such announcements </label> </div> </s: if> </form>
2. js Code
Function noTips () {var formParam = $ ("# form1 "). serialize (); // serialize the table content as a string $. ajax ({type: 'post', url: 'notice _ noTipsNotice ', data: formParam, cache: false, dataType: 'json', success: function (data) {}});}
3. NoticeAction code
/*** The checkbox does not prompt an announcement. You need to modify the blocking status in TBussinessSet, ajax asynchronous request */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 ());}}