Home > Web Front-end > JS Tutorial > jquery uses Taobao interface to query the location of mobile phone number across domains_jquery

jquery uses Taobao interface to query the location of mobile phone number across domains_jquery

WBOY
Release: 2016-05-16 17:11:57
Original
1608 people have browsed it

Copy code The code is as follows:

   

手机号码归属地查询


   

       

请输入手机号码


       
        查询
        号码有误 或 无数据
       

               
  • 手机号码:
  •            
               
  • 归属省份:

  •            
  • 运 营 商:

  •        

   

<script></p> <p><br>    var tel;<br>    var ajax=function(){<br>        //淘宝接口    <br>        $.ajax({<br>             type: "get",<br>             url: 'http://tcc.taobao.com/cc/json/mobile_tel_segment.htm?tel=' tel,<br>             dataType: "jsonp",<br>             jsonp: "callback",<br>             success: function(data){<br>                console.log(data);<br>                $('.error').css('display','none');<br>                var province = data.province,<br>                    operators = data.catName,<br>                    num = data.telString;</p> <p>                $('.num span').html(num);<br>                $('.province span').html(province);<br>                $('.operators span').html(operators);<br>             },<br>             error:function (){    <br>                $('li span').html('');<br>                $('.error').css('display','block');        <br>             }<br>         });<br>    }<br>    </p> <p>    var reg = /^(13|15|18)[0-9]{9}$/;//点击查询<br>    $('.button').click(function(){<br>        tel=$('input[type=text]').val();<br>        if(tel){<br>            if(reg.test(tel)){<br>                ajax();<br>            }else{<br>                $('li span').html('');<br>                $('.error').css('display','block');    <br>            }<br>        }<br>    });</p> <p>    //键盘事件<br>    $(window).keydown(function(event){<br>        tel=$('input[type=text]').val();<br>        if(event.keyCode==13) {<br>            if(tel){<br>                if(reg.test(tel)){<br>                    ajax();<br>                }else{<br>                    $('li span').html('');<br>                    $('.error').css('display','block');    <br>                }<br>            }<br>        }<br>    });</p> <p></script>

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template