Spring MVC enables front-and back-table interaction with Ajax

Source: Internet
Author: User

First look at the front desk Ajax section:
1$ (' #delMd '). Click (2             function(){3                 if($ (' #reqState '). val () = = ' 2 '){4$. Dialog.show ("The application form has been submitted for approval and can no longer be changed");5                     return false;6                 }7                 if($ ("#itemNo"). val () = = ' 0 '){8$. Dialog.show ("Please select master data to delete");9                     return false;Ten                 } One Jquery.ajax ({ AURL: "Create/delmd.htm", -Data: {"Reqno": $ ("#reqNo"). Val (), "ItemNo": $ ("#itemNo"). Val ()}, -Type: "POST", theErrorfunction(data) { -$. Dialog.show ("form submission error, please try again later"); -                     }, -Successfunction(data) { +                         if(!data.success) { -$. Dialog.show (' Delete failed '); +                             return; A                         }     at                         varReqname = $ (' #reqName '). Val (); -                     varReqno = $ (' #reqNo '). Val (); -                     varReqstate = $ (' #reqState '). Val (); -                     varPIID = $ (' #piid '). Val (); -$ (' #zcepcform ') [0].reset (); -$ (' #reqNo '). Val (reqno); in$ (' #reqState '). Val (reqstate); -$ (' #piid '). Val (piid); to$ (' #reqName '). Val (reqname); +$ ("#itemNo"). Val (0); - getmdlist (); the                     } *                 }); $                 return false; Panax Notoginseng             } -);
The data section can be used in this way, and you can also pass a form such as $ (' #testForm '). Serialize ()
The URL is the requested controller address
@RequestMapping ("zcepc/create/delmd.htm")    @ResponseBody    publicint  ItemNo ) {        = ZCEPCMANAGER.DELMD (reqno,itemno);         return ri;    }

Finally put the result in a result set. The foreground Ajax gets the background results, which are displayed in the page.

In this company to do projects are used in this structure, or very good understanding, is usually written code, pay more attention to some details, more thinking, write code before thinking is very important, which will let you less detours, avoid unnecessary time.

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.