Front-back and back-desk interaction

Source: Internet
Author: User

1. The foreground passes the value to the backstage

Submit Form Form

<formID= "SB"Action= "${pagecontext.request.contextpath}/admin/loancontract/addorupdate.do"Method= "POST">Various input boxes of various values<Buttonclass= "Tjbtn"ID= "SBM">Submitted</Button></form>

Submit a problem with the form: After the submission to the background, after successful, the background jump page can only jump to the response page, but want to keep on this page and pop alert, it can only this method, should add @responsebody

@RequestMapping ("Updateselfdomneed")
@ResponseBody Public voidupdateselfdomneed (httpservletrequest request,httpservletresponse response) {String TextArea= Request.getparameter ("TextArea"); String wishId= Request.getparameter ("WishId"); intCount =selfdomneedservice.updateselfneed (Wishid,textarea); Response.setcontenttype ("Text/html;charset=utf-8"); PrintWriter out=NULL; Try{ out=Response.getwriter (); if(count>0) {Out.print ("<script>alert (' processing success! ');" + "location.href= '/carexchange/admin/selfdomneed/selfdomneedlist.do ';</script>"); } Else{out.print ("<script>alert (' processing failed! '); location.href= '/carexchange/admin/selfdomneed/selfdomneedlist.do ';</script> "); Out.close (); } } Catch(IOException e) {e.printstacktrace (); } }

Use Ajax in JS

$ ("#sbm"). Click (function(){        varSP = $ ("#sp"). html (); if(sp!= ' trading order already exists! ‘){            $("#sb"). Submit (); return; } alert (' The trade order already exists or is empty! '); return;        }); $("#tradeCode"). Blur (function(){                varTradecode = $ ("#tradeCode"). Val (); $.ajax ({URL:"Checktradecode.do", Data:{tradecode:tradecode}, DataType:"JSON", Success:function(data) {vararr =eval (data); $("#sp"). HTML (Arr.code);            }        }); });

2.

  

Front-back and back-desk interaction

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.