日期:2014-05-17  浏览次数:20501 次

关于ajax 接收xml乱码问题?
一个PHP文件,从数据库中取出数据,用的xml返回给ajax,GB2312编码 get方式
PHP文件顶部已经定义
header("Content-Type: text/xml;charset=GBK");
但是在IE下还是空白的,其他浏览器正常,测试返回的数据换成英文的话是没问题的
有哪位遇到过这情况的,求指点……
一下为主要代码
ajax.php

header("Content-Type: text/xml;charset=GBK");
$sheng=$_REQUEST['pro'];
$info="";
$query="select name from pre_common_district where upid=$sheng";
$result=  mysql_query($query);
$info="<res>";
while($data=  mysql_fetch_assoc($result)){
            $info.="<city>".$data['name']."</city>";
        }
$info.="</res>";
echo $info;


ajax.js代码


if(http_request){
                                 
                                var url="myajax.php?pro="+$('sheng').selectedIndex;
                                //var data="pro=";
                                //window.alert(data);
                                http_request.open("get",url,true);
                                //http_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
                                http_request.onreadystatechange=chuli;
                                 
                                http_request.send();
                                 
                        }
 
function chuli
************
var cities=http_request.responseXML.getElementsByTagName("city");