Use JS to judge 60 seconds to the time, first define a variable refreshtime, when the event is triggered to check the success of the last request is now more than 60 seconds, if not more than 60 seconds, pop-up prompts,
Otherwise, the request is allowed to continue, after the success of the request, the current time assigned to Refreshtime, the specific way to achieve;
Copy Code code as follows:
UsingNamespace ("Biz.accountcenter") ["Cellphonevalidation"]={
refreshtime:0,//variable
Checkrefreshget:function (timelimit)/check time, timelimit the time required for incoming requests (in seconds), for example: 60
{
var nowtime = new Date ();
var nowminitepoint=nowtime.gethours () *3600+nowtime.getminutes () *60+nowtime.getseconds ();
if (nowminitepoint-biz.accountcenter.cellphonevalidation.refreshtime<timelimit)
{
return false;
}
return true;
},
Resetrefreshget:function ()///After the request succeeds, the method called to reset the defined variable 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 to start from how many seconds, such as: 60
{
var Showtimmer;
if (Showtimmer) {
Cleartimeout (Showtimmer);
}
if (timesecond==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 (Obj,page,iscancelphone)//Per request invocation method
{
if (! Biz.AccountCenter.CellPhoneValidation.checkRefreshGet (Dynamicvalidate.refreshtimelimit))//per request, JS check 60s time interval
{
$ ("#valiateerror"). Empty (). HTML ("<span class= ' Validform_wrong ' >" +$.newegg.format ($Resource. Buildcontent (" Accountcenter_modifydyanmic_cannotrepeatclick "), Dynamicvalidate.refreshtimelimit) +" </span> "). Show ();
$ ("#mobilewarning"). Hide ();
Return
}
$.get ("url", Data,function () {
If successful
Biz.AccountCenter.CellPhoneValidation.dynamicMessage (Dynamicvalidate.refreshtimelimit);/Countdown
Biz.AccountCenter.CellPhoneValidation.resetRefreshGet ()//Reset Time
});
}
}