日期:2014-05-17 浏览次数:20659 次
JSONP还是很不错的,下面这段代码放在任何地方都可以实时查询域名注册情况
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <link href="http://www.kejj.net/web/Tpl/default/Public/css/style.css" type="text/css" rel="stylesheet"> <script type="text/javascript" src="http://www.kejj.net/web/Tpl/default/Public/js/jquery.js"></script> <script type="text/javascript">$(document).ready(function(){ $("#endomainbutton").click(function(){ var rsboxDisplay=$("#domainrsbox").css("display"); if(rsboxDisplay=="none"){ $("#domainrsbox").slideDown("slow"); $("#domainrsHtml").html("域名查询中..."); }else{ $("#domainrsHtml").html("域名查询中..."); } var domainStr=""; var formStr=$("#endomainform").serialize(); var formArr=formStr.split("&"); for(i in formArr ){ var dtStr=formArr[i].split("="); if(dtStr[0]=="endomain"){ domainStr+=$("#endomainname").val()+dtStr[1]+","; } } $.ajax({ type:"get", url:"http://domain.api.kejj.net/api.php/Domain/checkDomain/domainStr/"+domainStr, timeout:999999, dataType:"jsonp", jsonp:"jsonpcallback", success:responseFun }); return false; }); $("#closeDomainrsbox").click(function(){ $("#domainrsbox").slideUp("slow"); }); }); function responseFun(data){ var rsHtml=""; $.each(data,function(i,v){ if(v[2]==211){ rsHtml+='<span class="reged">'+v[1]+' 不能注册</span><br />'; }else if(v[2]==210){ rsHtml+='<span class="reg">'+v[1]+' <a href="">立即抢注</a></span><br />'; } }); $("#domainrsHtml").html(rsHtml); } function refreshVerify(){ var timenow = new Date().getTime(); document.getElementById('verifyImg').src= '/index.php/Index/verify/'+timenow; } </script> </head> <body> <div class="domain-wrap1"><div class="domain-wrap2"><div class="domain-wrap3"><h2>域名查询</h2><form id="endomainform" name="endomainform" method="post" action=""><div class="form-title"><span class="www">WWW.</span><span class="input-domain-search"><input type="text" name="endomainname" id="endomainname" class="input-domain" /></span><span class="button"><input type="submit" name="button" id="endomainbutton" value="提交" class="submit" /></span></div><div class="form-content"><ul class="ulTable clearfix"><li><input name="endomain" type="checkbox" id="checkbox" value=".com" checked="checked" /> .com</li><li><input name="endomain" type="checkbox" id="checkbox" value=".net" checked="checked" /> .net</li><li><input name="endomain" type="checkbox" id="checkbox" value=".cn" checked="checked" /> .cn</li><li><input name="endomain" type="checkbox" id="checkbox" value=".com.cn" checked="checked" /> .com.cn</li><li><input name="endomain" type="checkbox" id="checkbox" value=".net.cn" checked="checked" /> .net.cn</li><li><input name="endomain" type="checkbox" id="checkbox" value=".org" /> .org</li><li><input name="endomain" type="checkbox" id="checkbox" value=".org.cn" /> .org.cn</li></ul><div id="domainrsbox"><div class="box2-t1"><div class="box2-t2"><div class="box2-t3"></div></div></div><div class="box2-content"><div id="closeDomainrsbox">关闭</div><div id="domainrsHtml"></div></div><div class="box2-b1"><div class="box2-b2"><div class="box2-b3"></div></div></div></div></div></form></div></div></div> </body> </html>?
?