DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> jQuery入門知識 >> JQuery特效代碼 >> 基於jquery實現發送文章到手機的代碼
基於jquery實現發送文章到手機的代碼
編輯:JQuery特效代碼     

前段時間做項目的時候寫的一段代碼,感覺挺實用,記錄下來分享給大家

代碼如下:
<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>發送文章到手機</caption>
    
                 <tr>
                  <td align="right" valign="middle"><label for="mphno">手機號</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="提 交"/></td>
                   <td colspan="2" align="center" id="short_n" style="display:none">請稍等</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 = "您訂閱的文章{$title}地址是:{$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":"您訂閱的文章《{$title}》地址是:{$url}",
        "rip":"{php echo ip()}",
       },
       error:function(data1,data2){
        alert(data2);
        alert("提交出錯!請稍後重試!");
       },
       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'>請正確填寫你的手機號</font></center></td>");
      return false;
     }
    });
    $("#fankui_2").click(function(){
     $(this).hide();
    })
            </script>

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved