Gunakan JS untuk menilai 60 detik untuk waktu, pertama -tama tentukan variabel refreshTime.
Kalau tidak, permintaan diizinkan. Setelah permintaan berhasil, waktu saat ini ditugaskan untuk menyegarkan waktu, dan metode implementasi spesifik;
Salin kode kode sebagai berikut:
MenggunakanNeNespace ("biz.accountcounder") ["cellphonevalidation"] = {
RefreshTime: 0, // Variabel
CheckRefreshget: function (timeLimit) // periksa waktu, timelimit adalah waktu (satuan detik) yang mengharuskan permintaan untuk diperkenalkan, seperti: 60
{{
var nowtime = new date ();
Var nowMinItePoint = nowtime.getHours ()*3600+nowtime.getMinutes ()*60+nowtime.getSeconds ();
If (nowminitepoint-biz.accountcenter.cellphonevalidation.refreshtime <timelimit) <timelimit)
{{
Mengembalikan false;
}
Kembali Benar;
},
Resetrefreshget: function () // Setelah permintaan berhasil, metode panggilan diatur ulang ke waktu saat ini
{{
var nowtime = new date ();
Var nowMinItePoint = nowtime.getHours ()*3600+nowtime.getMinutes ()*60+nowtime.getSeconds ();
Biz.accountcenter.cellphonevalidation.refreshtime = nowminitepoint;
},
DynamicMessage: Function (Timesecond) // Metode Countdown TimeSecond berasal dari berapa detik mulai dari, seperti: 60
{{
var showmer;
if (showTimmer) {
ClearTimeout (Showmer);
}
ifsecond == DynamicValidate.RefreshTimelimit)
{{
var messagerefresh = $.
$ ("#spanrefresh").
$ ("#spanrefresh").
Waktu waktu;
}
showTimmer = setTimeout (function () {
var messagerefresh = $.
$ ("#spanrefresh").
Waktu waktu;
if (timeecond <0) {
ClearTimeout (Showmer);
$ ("#spanrefresh").
$ ("#spanrefresh").
} Kalau tidak {
Biz.accountcenter.cellphonevalidation.dynamicmessage (timeecond);
$ ("#spanrefresh").
}
}, 1000);
},
Buat: Fungsi (OOJ, halaman, iScancelphone) //
{{
If (! Biz.accountCenter.cellphonevalidation.checkrefreshget (DynamicValidate.RefreshTimelimit)) // Setiap permintaan, JS memeriksa interval waktu 60S antara interval waktu 60 -an.
{{
$ ("#ValiateError"). span> "). show ();
$ ("#MobileWarning").
Kembali;
}
$ .get ("url", data, function () {{) {
// jika berhasil
Biz.accountcenter.cellphonevalidation.dynamicmessage (DynamicValidate.RefreshTimelimit);
Biz.accountcenter.cellphonevalidation.resetheshget ();
});
}
}