关于ajax 接收xml乱码有关问题

WBOY
Release: 2016-06-13 13:00:56
Original
768 people have browsed it

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

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


ajax.js代码

<br>
if(http_request){<br>
                                 <br>
                                var url="myajax.php?pro="+$('sheng').selectedIndex;<br>
                                //var data="pro=";<br>
                                //window.alert(data);<br>
                                http_request.open("get",url,true);<br>
                                //http_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");<br>
                                http_request.onreadystatechange=chuli;<br>
                                 <br>
                                http_request.send();<br>
                                 <br>
                        }<br>
 <br>
function chuli<br>
************<br>
var cities=http_request.responseXML.getElementsByTagName("city");<br>
 <br>
                                 <br>
                                 <br>
                                //把返回的城市动态添加到city控件 <div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!