<! DOCTYPE HTML Public"-//W3C//DTD XHTML 1.0 transitional//en" "HTTP://WWW.W3.ORG/TR/XHTML1/DTD/XHTML1-TRANSITIONAL.DTD">"http://www.w3.org/1999/xhtml">"Scripts/jquery-2.1.1.min.js"Type="Text/javascript"></script> <script type="Text/javascript">varIntervalobj;//timer variable, control time varCount = -;//interval function, 1 second execution varCurcount;//current number of seconds remaining \ varCode ="";//Verification Code varCodelength =6;//Verification Code Lengthfunction SendMessage () {Curcount=count; varDealtype = $ ("#phones"). Val ();//Mobile phone number varUID = $ ("#uid"). Val ();//User uid//Generate verification Code for(vari =0; i < codelength; i++) {Code+ = parseint (Math.random () *9). toString (); } //Set button effect to start timing$("#btnSendCode"). attr ("Disabled","true"); $("#btnSendCode"). Val ("Please check the"+ Curcount +"Enter the verification code in seconds"); Intervalobj= Window.setinterval (Setremaintime, +);//start Timer, execute once in 1 seconds//send processing data to the background$.ajax ({type:"POST",//transfer by postDataType:"text",//data format: JSONUrl:'admins/index6',//Destination AddressData"dealtype="+ Dealtype +"&uid="+ UID +"&code="+Code, Error:function (XMLHttpRequest, Textstatus, Errorthrown) {},//Error HandlingSuccess:function (msg) {}//return content }); } //Timer handler functionfunction Setremaintime () {if(Curcount = =0) {window.clearinterval (intervalobj);//Stop Timer$("#btnSendCode"). Removeattr ("Disabled");//Enable button$("#btnSendCode"). Val ("Resend Verification Code"); Code="";//clear the verification code. If you do not clear, after the time, the input received the verification code is still valid } Else { //cooldown 60 seconds button to clickcurcount--; $("#btnSendCode"). Val ("Please check the"+ Curcount +"Enter the verification code in seconds"); } } </script> Verification Code"ImaCode2"Src="validcode.ashx"onclick="this.src= ' validcode.ashx?number= ' +math.random ()"/> <p> Mobile number: <input id="Phones"Type="text"Value=""/> </p> <P> user name: <input id="UID"Type="text"Value=""/> </P> <p><input id="Btnsendcode"Type="Button"Value="Send Verification Code"onclick="sendMessage ()"/></p></body>The code under the controller
[HttpPost] PublicActionResult Index6 () {stringZH ="XXXXXXX";//SMS Interface Account stringMM ="123456";//account Password intSms_type = the;//channel numberstringDealtype = request["Dealtype"];//Phone number stringUID = request["UID"];//User ID stringCode = request["Code"];//Random Number
ContentstringNR ="Hello User:"+ UID +", your verification code is:"+Code+"Please enter as soon as possible!";
SMS interface channel address such as:stringURL ="http://www.6610086.net/jk.aspx?zh="+ ZH +"8&mm="+ mm +"&hm="+Dealtype+"&nr="+ NR +"&sms_type="+Sms_type; Response.Redirect (URL); //Response.Write ("<script>$.ajax" ({type: ' POST ', DataType: ' text ', url: "+ URL +", Data:null,error:function (XML HttpRequest, Textstatus, Errorthrown) {},success:function (msg) {}});</script> "); //Response.Write ("<script>$.ajax ([Type: ' POST ', DataType: ' text ',]);</script>"); returnView (); }
jquery realizes the countdown effect after clicking the button, it is used for sending the mobile phone verification code.