如果你对该文章中的内容有疑问/不解,可以点击此处链接提问
要注明问题和此文章链接地址 点击此处跳转
PHP通用的生成新浪t.cn的短域名小工具!
<form method="get" id="searchform" action="/"> <span class="scdwz"> <input type="text" value="" name="s" id="url" placeholder="短网址生成输入网址" required/><button class="fxaniu fxaniu1" type="submit" id="form">生成</button></span> </form> <script>$("#form").click(function(){$.ajax({url:"https://cgi.qiangwl.com/dwz.cgi?format=jsonp&api=sina&url="+$('#url').val(),dataType:"jsonp",jsonp:"callback",beforeSend:function(XMLHttpRequest){$("#form").attr("disabled",true)},success:function(a){var strJson=JSON.stringify(a);obj=$.parseJSON(strJson),$("#form").attr("disabled",false);$("#url").val(obj.short)},error:function(a){$("#form").attr("disabled",false);alert('失败')}})});</script>
CSS代码: #searchform{padding:2px} .scdwz input{float:left;padding:2px 10px;width:75%;height:37px;border:1px solid #5db8f8;border-radius:2px 0 0 2px;background:#ebebeb;font:14px "Microsoft YaHei",Helvetica;line-height:37px;-webkit-appearance:none} .scdwz button{position:relative;overflow:visible;width:25%;height:37px;border:0;border-radius:0 2px 2px 0;background:#5db8f8;color:#fff;cursor:pointer}