php返回的xmlHttp.status的值一直是403,forbidden,怎么办啊~~~~ 20
这是在一个html页面中的javascript:<scriptlanguage="javascript"type="text/javascript">varxmlHttp...
这是在一个html页面中的javascript:
<script language="javascript" type="text/javascript">
var xmlHttp = false;
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
xmlHttp = false;
}
}
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
xmlHttp = new XMLHttpRequest();
}
function callServer() {
var date=new Date();
temp=date.getTime();
//if ((u_name == null) || (u_name == "")) return false;
//var url="check.php?timestamp="+temp+"&id="+u_name;
var u_name = document.getElementById("userid").value;
xmlHttp.open("GET","check.php?timestamp="+temp+"&id="+u_name, true);
xmlHttp.onreadystatechange = updatePage;
xmlHttp.send(null);
}
function updatePage() {
if (xmlHttp.readyState < 4) {
user_id.innerHTML="loading...";
}
if (xmlHttp.readyState == 4) {
if(xmlHttp.status==200)
{
result=xmlHttp.responseText;
c=document.getElementById("user_id");
c.innerHTML=result;
}
else
{alert("执行过程中出现问题,服务器返回"+xmlHttp.statusText);}
}
}
</script>
php如下:
<?php
header("Content-Type:text/html; charset=UTF-8");
$id=$_GET["id"];
mysql_connect("localhost","root","123456");
mysql_select_db("infornet");
mysql_query("SET NAMES GB2312");
$sql="SELECT COUNT(*) FROM user WHERE uno='$id'";
$result=mysql_query($sql);
$num=mysql_fetch_row($result);
if($num[0]==0)
echo "1";
else
echo "0";
?>
每次执行都是红色的那句话,谢谢大家帮个忙啊~~~ 展开
<script language="javascript" type="text/javascript">
var xmlHttp = false;
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
xmlHttp = false;
}
}
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
xmlHttp = new XMLHttpRequest();
}
function callServer() {
var date=new Date();
temp=date.getTime();
//if ((u_name == null) || (u_name == "")) return false;
//var url="check.php?timestamp="+temp+"&id="+u_name;
var u_name = document.getElementById("userid").value;
xmlHttp.open("GET","check.php?timestamp="+temp+"&id="+u_name, true);
xmlHttp.onreadystatechange = updatePage;
xmlHttp.send(null);
}
function updatePage() {
if (xmlHttp.readyState < 4) {
user_id.innerHTML="loading...";
}
if (xmlHttp.readyState == 4) {
if(xmlHttp.status==200)
{
result=xmlHttp.responseText;
c=document.getElementById("user_id");
c.innerHTML=result;
}
else
{alert("执行过程中出现问题,服务器返回"+xmlHttp.statusText);}
}
}
</script>
php如下:
<?php
header("Content-Type:text/html; charset=UTF-8");
$id=$_GET["id"];
mysql_connect("localhost","root","123456");
mysql_select_db("infornet");
mysql_query("SET NAMES GB2312");
$sql="SELECT COUNT(*) FROM user WHERE uno='$id'";
$result=mysql_query($sql);
$num=mysql_fetch_row($result);
if($num[0]==0)
echo "1";
else
echo "0";
?>
每次执行都是红色的那句话,谢谢大家帮个忙啊~~~ 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询