About xml garbled characters received by ajax

Source: Internet
Author: User
About xml garbled characters received by ajax? A php file that extracts data from the database and returns the data in xml to ajax. the header (Content-Type: & nbsp; textxml;) has been defined at the top of the get php file; charsetGBK); however, it is still blank in IE. other browsers are normal. if the returned data is changed to English, it is no problem. Which of the following has encountered this issue about xml garbled characters received by ajax?
A php file that extracts data from the database and returns the data to ajax in xml format. the get method is encoded in GB2312.
Php file top defined
Header ("Content-Type: text/xml; charset = GBK ");
However, it is still blank in IE, and other browsers are normal. if the data returned by the test is changed to English, it is OK.
Which of the following has met this situation ......
Below is the main code
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=" ";
while($data= mysql_fetch_assoc($result)){
$info.=" ".$data['name']." ";
}
$info.=" ";
echo $info;


Ajax. js code


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 ");



// Dynamically add the returned city to the city control

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.