Php ajax中的Xmlhttp错误

Php ajax中的Xmlhttp错误,php,mysql,ajax,Php,Mysql,Ajax,我有国家和州选择框,它根据国家的选择加载。这段代码在脱机状态下运行良好,但当我将其放到服务器上时,它会显示(使用XMPHTTP时出现问题:找不到) 函数getXMLHTTP(){//返回xml http对象的函数 var xmlhttp=false; 试一试{ xmlhttp=新的XMLHttpRequest(); } 第(e)款{ 试试{ xmlhttp=新的ActiveXObject(“Microsoft.xmlhttp”); } 捕获(e){ 试一试{ xmlhttp=新的ActiveX

我有国家和州选择框,它根据国家的选择加载。这段代码在脱机状态下运行良好,但当我将其放到服务器上时,它会显示(使用XMPHTTP时出现问题:找不到)


函数getXMLHTTP(){//返回xml http对象的函数
var xmlhttp=false;
试一试{
xmlhttp=新的XMLHttpRequest();
}
第(e)款{
试试{
xmlhttp=新的ActiveXObject(“Microsoft.xmlhttp”);
}
捕获(e){
试一试{
xmlhttp=新的ActiveXObject(“Msxml2.xmlhttp”);
}
渔获物(e1){
xmlhttp=false;
}
}
}
返回xmlhttp;
}
函数getState(cate_id){
var strURL=“findsect.php?country=“+cate\u id;
var req=getXMLHTTP();
如果(请求){
req.onreadystatechange=函数(){
如果(req.readyState==4){
//只有在“OK”的情况下
如果(请求状态==200){
document.getElementById('statediv')。innerHTML=req.responseText;
}否则{
警报(“使用XMLHTTP:\n“+req.statusText时出现问题”);
}
}               
}           
请求打开(“获取”,strURL,true);
请求发送(空);
}       
}
此代码位于findsect.php中

  <html>
    <head>
    <title></title>
    <style type="text/css">
    .input-short { 
        width: 25% 
        }
    </style>
    </head>

    <?php 
    $country=$_GET['country'];
    $con = mysql_connect('localhost','root',''); 
    if (!$con) {
        die('Could not connect: ' . mysql_error());
    }
    mysql_select_db('my');
    $query="SELECT * FROM gallery_section WHERE related='$country'";
    $result=mysql_query($query);

    ?>
    <select class="input-short" name="Section" onchange="getCity(<?php echo $country?>,this.value)">
    <option>Select Section</option>
    <?php while ($row=mysql_fetch_array($result)) { ?>
    <option value="<?php echo $row['title']?>"><?php echo $row['title']?></option>
    <?php } ?>
    </select>
    </html>

.input short{
宽度:25%
}

使用var strURL=“findsect.php?country=“+cate\u id;可能是findsect.php找不到文件不在那里。另一种解决方案?危险:您正在使用并且应该使用。您还容易受到现代API的攻击,因为它会使您从中更轻松。@user331424-服务器说文件不在那里。我倾向于相信这一点。使用浏览器中的开发人员工具找出实际请求的URL,并将其与服务器的错误日志进行比较
  <html>
    <head>
    <title></title>
    <style type="text/css">
    .input-short { 
        width: 25% 
        }
    </style>
    </head>

    <?php 
    $country=$_GET['country'];
    $con = mysql_connect('localhost','root',''); 
    if (!$con) {
        die('Could not connect: ' . mysql_error());
    }
    mysql_select_db('my');
    $query="SELECT * FROM gallery_section WHERE related='$country'";
    $result=mysql_query($query);

    ?>
    <select class="input-short" name="Section" onchange="getCity(<?php echo $country?>,this.value)">
    <option>Select Section</option>
    <?php while ($row=mysql_fetch_array($result)) { ?>
    <option value="<?php echo $row['title']?>"><?php echo $row['title']?></option>
    <?php } ?>
    </select>
    </html>