jquery Ajax Success callback function in the implementation of the button Ash Countdown _jquery

Source: Internet
Author: User
The main is to realize the success of the asynchronous mobile phone sent SMS in the AJAX success callback in the implementation will send the button to set the Ash and countdown, just started to report JS error, the problem may be that after invoking Ajax this is updated, at any time before this object assigned to a variable is no problem

Button Countdown Code
Copy Code code as follows:

var wait = 60;
Get_code_time = function (o) {
if (wait = = 0) {
O.removeattribute ("Disabled");
O.value = "Free access to verification code";
wait = 60;
} else {
O.setattribute ("Disabled", true);
O.value = "(" + wait + + ") seconds to retrieve again";
wait--;
settimeout (function () {
Get_code_time (o)
}, 1000)
}
}

Call Get_code_time function code after getting SMS
Copy Code code as follows:

//re-acquire Authenticode
$ (' #codeagain '). Click (function () {
var o = this;
$.ajax ({
URL: "tea_sendcode.action?jsoncallback=?",
Type: "POST",
Data: {Accountid:accountid},
D Atatype: "JSON",
Success:function (data) {
if (data.status = 1 && data.code = =) {
Alert ("Authenticode Sent to your phone ");
Get_code_time (o);
} else {

if (data.msg!= "") {
alert (data.msg);
} else {
alert ("SMS authentication code failed to send)";
}
}
},
Error:function (data) {
if (Data.status = = 0) {
alert (data.msg);
} else {
alert ("SMS authentication code failed to send)";
}
}
});
});

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.