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