域名检查接口

文件一(页面文件):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>域名检查接口</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script src="javascript/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
function chk()
{
var domain = $("#domain").val();
// var check_url="http://panda.www.net.cn/cgi-bin/check.cgi?area_domain="+domain;
var check_url="http://panda.www.net.cn/cgi-bin/check.cgi?area_domain=hichina.com";
$.ajax({
     type:"get",
     cache:false,
     datatype: "text",
     url:"ajax_tt.php?area_domain="+domain,
     success:function(data){
     $("#domain_result").html(data);
     }
     });

}
</script>
</head>
<body>

<h1>域名检查接口</h1>

<div>
<form >
   请输入域名:<input id="domain" type="text" value="skox.cn" />
   <input type="button" value="查询" οnclick="chk()" />
</form>
</div>
<div id="domain_result">

</div>
</body>
</html>

文件二(被ajax调用的php文件):

<?php
$url = 'http://panda.www.net.cn/cgi-bin/check.cgi?area_domain='.$_GET['area_domain'];
$contents = file_get_contents($url);
$xml = simplexml_load_string($contents);
if (!empty($xml)) {
switch($xml->original)
{
   case '210 : Domain name is available':$result='域名可以注册';break;
   case '211 : Domain name is not available':$result='域名已经注册';break;
   case '212 : Domain name is invalid':$result='域名参数传输错误';break;
   case '214 : Unknown error' :$result='未知错误';break;
}
}
echo iconv("gb2312", "utf-8",$result);
?>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值