向send.php提交了用戶的mobile,怎么實作將用戶的mobile提交給mail.php向管理員發送郵件,請老師們幫忙寫下
<input id="mobile" type="tel" placeholder="手機號碼" value="">
<button id="btnCheckCode">立即發送</button>
$(function () {
var InterValObj; //timer變數,控制時間
var count = 60; //間隔函式,1秒執行
var curCount;//當前剩余秒數
$('#btnCheckCode').click(function () {
if($("#mobile").val()==""){
tankuang(240, "請輸入您的手機號碼");
return false;
}
if(!$("#mobile").val().match(/^1[3|4|5|6|7|8|9]{1}[0-9]{9}$/)){
tankuang(240, "手機號碼格式不正確!請重新輸入!");
return false;
}
var captcha1 = new TencentCaptcha('211222204', function(res) {
if(res.ret === 0){
var mobile = $.trim($("#mobile").val());
// save tbl_smsCode, and send sms
generateCode(mobile);
}
});
captcha1.show(); // 顯示驗證碼
});
//發送手機到后臺,生成驗證碼
var generateCode = function(mobile,verify) {
var args = {
mobile: mobile,
verify: verify,
}
$.post('send.php', args, function(result) {
if (result.status==0) {
tankuang(240, "成功");
// 60s 倒數
curCount = count;
$("#btnCheckCode").attr("disabled", "true");
$("#btnCheckCode").addClass("button-light");
$("#btnCheckCode").html(curCount + " s");
InterValObj = window.setInterval(SetRemainTime, 1000); //啟動計時器,1秒執行一次
}
else{
tankuang(200, "失敗,請聯系我們核實");
}
}, 'json');
};
//timer處理函式
var SetRemainTime = function() {
if (curCount == 0) {
window.clearInterval(InterValObj);//停止計時器
$("#btnCheckCode").removeAttr("disabled");//啟用按鈕
$("#btnCheckCode").removeClass("button-light");
$("#btnCheckCode").html("獲取驗證碼");
}
else {
curCount--;
$("#btnCheckCode").html(curCount + " s");
}
};
function tankuang(pWidth,content,url)
{
$("#msg").remove();
var html ='<div id="msg" style="position:fixed;top:50%;width:100%;height:30px;line-height:30px;margin-top:-15px;z-index:9999;"><p style="background:#000;opacity:0.8;width:'+ pWidth +'px;color:#fff;text-align:center;padding:10px 10px;margin:0 auto;font-size:14px;border-radius:4px;">'+ content +'</p></div>';
$("body").append(html);
var t=setTimeout(next,4000);
function next()
{
$("#msg").remove();
if(url!= undefined){
window.location.href = url;
}
}
}
})
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/269044.html
標籤:Ajax
上一篇:b:hover時控制a的變化,這既不是父子也不是兄弟,沒有不用js就可以控制的辦法,求解!!
下一篇:如何編輯子項?
