Use JS to judge 60 seconds to timing, first define a variable refreshtime. When triggering the event, check whether the time for the last request is more than 60 seconds.
Otherwise, the request is allowed. After the request is successful, the current time is assigned to Refreshtime, and the specific implementation method;
Copy code code as follows:
USINGNAMESPACE ("biz.accountCounder") ["cellphonevalidation"] = {
RefreshTime: 0, // Variable
CheckRefreshget: Function (Timelimit) // Check the time, Timelimit is time (unit seconds) that requires the request to be introduced, such as: 60
{{
var nowtime = new date ();
Var NowminitePoint = Nowtime.getHours ()*3600+Nowtime.getminutes ()*60+Nowtime.getSeconds ();
IF (nowminitepoint-biz.accountcenter.cellphonevalidation.refreshtime <Timelimit) <Timelimit)
{{
Return false;
}
Return true;
},
ResetRefreshget: Function () // After the request is successful, the call method is reset to the current time
{{
var nowtime = new date ();
Var NowminitePoint = Nowtime.getHours ()*3600+Nowtime.getminutes ()*60+Nowtime.getSeconds ();
Biz.accountcenter.cellphonevalidation.refreshtime = nowminitepoint;
},
dynamicMessage: Function (TimeSecond) // Countdown method TimeSecond is from how many seconds starting from, such as: 60
{{
var showtimmer;
if (showtimmer) {
Cleartimeout (showtimmer);
}
ifSecond == Dynamicvalidate.refreshtimelimit)
{{
var messageRefresh = $. Newegg.Format (Dynamicvalidate.refreshspanmessage, TimeSecond);
$ ("#spanrefresh"). html (<Span> "+MessageRefresh+" </span> ");
$ ("#spanrefresh"). Attr ("class", "Button btn_yanz_disable");
Timesecond-;
}
showtimmer = settimeout (function () {
var messageRefresh = $. Newegg.Format (Dynamicvalidate.refreshspanmessage, TimeSecond);
$ ("#spanrefresh"). html (<Span> "+MessageRefresh+" </span> ");
Timesecond-;
if (timeSecond <0) {
Cleartimeout (showtimmer);
$ ("#spanrefresh"). Attr ("class", "Button btn_yanz");
$ ("#spanrefresh"). html (<span> "+dynamicvalidate.refreshmessage+" </span> ");
} Else {
Biz.accountcenter.cellphonevalidation.dynamicmessage (timeSecond);
$ ("#spanrefresh"). Attr ("class", "Button btn_yanz_disable");
}
}, 1000);
},
Create: Function (OOJ, PAGE, Iscancelphone) //
{{
If (! BIZ.ACCOUNTCENTER.CellPhonevalidation.CheckRefreshget (Dynamicvalidate.refreshtimelimit)) // Each request, JS checks the 60S time interval between 60S time interval.
{{
$ ("#Valiateerror"). Empty (). html ("<span class = 'value_wrong'>"+$. Newegg.Format ($ Resource.BuildContent ("AccountCountCinger_modifyDydyDydy Anmic_cannotrepetClick "), dynamicvalidate.refreshtimelimit)+" </span > "). show ();
$ ("#MobileWarning"). Hide ();
Return;
}
$ .get ("url", data, function () {{) {
// If successful
Biz.accountcenter.cellphonevalidation.dynamicmessage (dynamicvalidate.refreshtimelimit);
Biz.accountcenter.cellphonevalidation.resetReshget (); // reset time
});
}
}