Based on jquery to send articles to the phone code

  • 2020-05-10 17:36:50
  • OfStack

I wrote a piece of code when I was doing the project some time ago, which felt very practical, so I wrote it down and Shared it with you


<a class="btn_fankui relative" id="btn_fankui" style="top:7px;">
        <div class="qr_content" id="fankui_1" style="top:40px; left:-25px;">
         <span></span>
         <form class="fankui_form" action=""> 
                <table>
    <caption> Send an article to your phone </caption>
    
                 <tr>
                  <td align="right" valign="middle"><label for="mphno"> Mobile phone no. </label></td>
                   <td><input class="input" name="mphno" type="text" id="input_phone"/></td>
                  </tr>
      <tr id="p_memssage">
     
                  </tr>
                 <tr>
                   <td colspan="2" align="right" id="short_d"><input name="" type="button" class="fankui_tijiao" value=" mention   Hand in "/></td>
                   <td colspan="2" align="center" id="short_n" style="display:none"> Please wait a moment </td>
                  </tr>
                </table>
          </form>
        </div>
        </a>
   <script type="text/javascript">
                $("#btn_fankui").toggle(function(){
                    $("#fankui_1").fadeIn(1);},
                function(){
                    $("#fankui_1").fadeOut(1);});
                     $("#fankui_1").click(function(e){e.stopPropagation();});
    $(".fankui_tijiao").click(function(){
     var phone = $("#input_phone").val();
     var content = " The articles you subscribe to {$title} The address is: {$url}";
     var p1 = /^((\(\d{3}\))|(\d{3}\-))?13\d{9}|15\d{9}$/;
     if (p1.test(phone)){
      $("#p_memssage").html("");
      $.ajax({
       url:"{APP_PATH}index.php?m=content&c=phone&a=sms",
       type:"POST",
       dataType:"html",
       data:{
        "id":"{$id}",
        "mobile":phone,
        "content":" The articles you subscribe to {$title} ) address: {$url}",
        "rip":"{php echo ip()}",
       },
       error:function(data1,data2){
        alert(data2);
        alert(" Submit an error ! Please try again later !");
       },
       beforeSend:function(){
        $("#short_d").hide();
        $("#short_n").css("display","block");
       },
       success:function(data){
        $("#fankui_1").css("display","none");
        $("#short_d").show();
        $("#short_n").css("display","none");
        alert(data);
       }
      });
       
     }else{
      $("#p_memssage").html("<td colspan='2'><center><font color='red'> Please fill in your mobile phone number correctly </font></center></td>");
      return false;
     }
    });
    $("#fankui_2").click(function(){
     $(this).hide();
    })
            </script>


Related articles: