sendsms2.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. function sendmsgbutton(){
  2. if ($("#mobile").val()=="") {
  3. alert("请输入手机号码");
  4. $("#mobile").focus();
  5. return;
  6. }
  7. var aj = $.ajax( {
  8. url:'index.php?',
  9. data:{ phonenum : $("#mobile").val() , mod:"sendsms" },
  10. type:'post',
  11. cache:false,
  12. dataType:'json',
  13. success:function(data) {
  14. if($.trim(data) =="success" ){
  15. }else{
  16. }
  17. },
  18. error : function() {
  19. }
  20. });
  21. var test = {
  22. node:null,
  23. count:120,
  24. start:function(){
  25. if(this.count > 0){
  26. this.count--;
  27. this.node.value = this.count + "秒后可重新获取";
  28. var _this = this;
  29. setTimeout(function(){
  30. _this.start();
  31. },1000);
  32. }else{
  33. this.node.removeAttribute("disabled");
  34. this.node.setAttribute("class","disabled");
  35. this.node.value=("再次发送");
  36. this.count = 120;
  37. }
  38. },
  39. init:function(node){
  40. this.node = node;
  41. this.node.setAttribute("disabled",true);
  42. this.node.setAttribute("class","disable");
  43. this.start();
  44. }
  45. };
  46. var btn = document.getElementById("sendmsg");
  47. test.init(btn);
  48. }