JQuery uses $. ajax and checkbox to implement the function of not notifying users next time. jquery. ajax

Source: Internet
Author: User

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 ());}}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.