Simple Description: on demand, after the password is changed, there will be a countdown of 3 seconds. After the countdown is completed, the logon page will be returned, instead of changing the password. The logon page will be returned immediately.
Code:
// Html code <Div class = "Portlet light bordered" id = "loginbox">
<Div class = "tab-content">
<Div class = "row">
<Form action = "" class = "horizontal-form" method = "Post" id = "searchform" AutoComplete = "off">
<Div class = "col-md-12">
<Div class = "col-md-6">
<Label class = "control-label Flex" style = "margin-top: 10px;">
Original password:
</Label>
</Div>
</Div>
<Div class = "col-md-12">
<Div class = "col-md-6">
<Div class = "control-group">
<Div class = "controls">
<Div class = "main_input_box">
<Input type = "password" name = "name" id = "passwordori" class = "form-control"
Placeholder = "Enter the original password"
Maxlength = "50" allowkeyboard = "true" value = ""/>
</Div>
</Div>
</Div>
</Div>
</Div>
<Div class = "col-md-12">
<Div class = "col-md-6">
<Label class = "control-label Flex" style = "margin-top: 10px;">
New password:
</Label>
</Div>
</Div>
<Div class = "col-md-12">
<Div class = "col-md-6">
<Div class = "control-group">
<Div class = "controls">
<Div class = "main_input_box">
<Input type = "password" name = "name" id = "passwordnew" class = "form-control"
Placeholder = "enter a new password"
Maxlength = "50" allowkeyboard = "true" value = ""/>
</Div>
</Div>
</Div>
</Div>
</Div>
<Div class = "col-md-12">
<Div class = "col-md-6">
<Label class = "control-label Flex" style = "margin-top: 10px;">
Confirm new password:
</Label>
</Div>
</Div>
<Div class = "col-md-12">
<Div class = "col-md-6">
<Div class = "control-group">
<Div class = "controls">
<Div class = "main_input_box">
<Input type = "password" name = "name" id = "passwordcon" class = "form-control"
Placeholder = "confirm new password"
Maxlength = "50" allowkeyboard = "true" value = ""/>
</Div>
</Div>
</Div>
</Div>
</Div>
</Form>
<Div class = "col-md-6" style = "margin-top: 10px; float: Right; clear: Right" id = "showmsg">
<Button class = "BTN sbold default" id = "resetconten" style = "float: Right; margin-left: 10px;">
<SPAN class = "Ladda-label"> clear </span>
</Button>
<Button class = "BTN sbold blue" id = "Confirm" style = "float: right;">
<SPAN class = "Ladda-label" onclick = "checkserver ()"> confirm modification </span>
</Button>
</Div>
</Div>
</Div>
</Div>
// JS Code $. Ajax ({
Type: "Post ",
URL: rootpath + '/PRI/user/changepassword ',
Data: {keydata: Code },
Datatype: 'json ',
Cache: false,
Success: function (data ){
If ("success" = data. Result ){
$ ("# Loginbox"). Tips ({
SIDS: 1,
MSG: "The modification is successful. The logon page will be returned in 3 seconds. Please log on again! ",
BG: '# ff5080 ',
Time: 3
});
VaR T = parseint (3 );
Window. setinterval (function (){
If (T> 0 ){
$ ("# Showmsg" cmd.html ('remaining <a class = "flip-link BTN-Info">' + T + 'second' + '</a> second refresh ');
} Else {
VaR Path = rootpath + 'main/logout ';
Top. Location. href = path;
}
T --;
},1000 );
} Else if ("fail" = data. Result ){
$ ("# Passwordori"). Tips ({
Side: 1,
MSG: "Incorrect original password input ",
BG: '# ff5080 ',
Time: 3
});
$ ("# Passwordori"). Focus ();
Return false;
} Else {
$ ("# Passwordori"). Tips ({
Side: 1,
MSG: "exception ",
BG: '# ff5080 ',
Time: 3
});
$ ("# Passwordori"). Focus ();
Return false;
}
}
});
Conclusion: The Code mainly uses window. setinterval (code, delay
For more information, see https://developer.mozilla.org/zh-CN/docs/Web/API/Window/setInterval
After the password is successfully modified, the logon page is displayed three seconds after the countdown.