Front and rear interaction, use AJAX to transfer parameters, but not jump to the back of the path

Source: Internet
Author: User

function Setpaypwd () {
var Mobile=document.getelementbyid ("Telphone"). Value;
var Paypassword=document.getelementbyid ("Paypwd"). Value;
var Repaypassword=document.getelementbyid ("Repaypwd"). Value;
Alert ("mobile=" +mobile+ "and" + "paypassword=" +paypassword);
if (Paypassword!=repaypassword) {
Alert ("Please reset the password before and after entering it!");
$ ("#payPwd"). focus ();
Return
}
Alert ("Password consistent, start interacting");

Front-back and back-desk interaction
$.ajax ({
Type: "POST",//Transmit by post
DataType: "JSON",//Data format: JSON
URL: ' ${path}/member/setpaypwd.shtml ',//Destination address
Data: {mobile:mobile, Paypassword:paypassword},
Error:function (XMLHttpRequest, Textstatus, Errorthrown) {},
Success:function (msg) {
if (Msg.ret!=1) {
Layer.msg (MSG.MSG);
}else{
Layer.msg (' Verify success, please set payment password! '), {
time:1000//2 seconds Off (default is 3 seconds if not configured)
}, function () {
Window.location.href= "${path}/goods/index.shtml";
});
}
}
});
Alert ("Setup succeeded! ");

}
The statement that triggers this method;
<input type= "button" onclick= "Setpaypwd ()" value= "Commit"/>


Background Receive code:

@RequestMapping ("/setpaypwd")
Public String setpaypwd (modelmap mm,string mobile,string paypwd) {
Jsonobject json = new Jsonobject ();
map<string, object> returnmap = new hashmap<string,object> ();
if (Stringutil.isblank (mobile) | | Stringutil.isblank (paypwd)) {
JSON = Getjson (0, NULL, "parameter missing!");
}
map<string,string> map = new hashmap<string,string> ();
Map.put ("Membermobile", mobile);
Map.put ("Memberpaypwd", paypwd);
Returnmap = Shopmemberservice.login (map);
if (returnmap!=null&& (String) returnmap.get ("Isresult"). Equals ("0")) {
Json.put ("ret", 1); 0 Failure 1 Successes
Json.put ("Data", Returnmap); Return data
Json.put ("MSG", "Set success!"); Return message
SetUser (RETURNMAP);
}else{
JSON = Getjson (0, NULL, (String) returnmap.get ("membermsg"));
}
Mm.put ("JSON", JSON);
return ajax_return;

}

Welcome to join the Web front-end interactive communication Group 04, a huge amount of learning materials free delivery

Front and rear interaction, use AJAX to transfer parameters, but not jump to the back of the path

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.