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