Garbled Ajax
This garbled how to solve!!! My code is all posted:
0) {$sql = "Select username from Phpcms_member WHERE username like '". $queryString. " % ' LIMIT 0,15 '; echo $sql; $query = mysql_query ($sql), while ($result = Mysql_fetch_array ($query)) {$value = $result [' Username '];echo '
'. $value. '';}}? >
Htm:
Ajax Search Capabilities
Reply to discussion (solution)
Someone please help look, O (∩_∩) o Thank you
Someone please help look, O (∩_∩) o Thank you
Ajax for Chinese processing, you'd better do a bit of conversion, because the coding problem caused by
Because you have the header (' CONTENT-TYPE:TEXT/HTML;CHARSET=GBK ');
So Ajax will interpret the returned content as GBK
But Ajax always sends data out of Utf-8.
So you $queryString = $_post[' queryString ');
Get the data that is UTF-8 encoded when you echo $sql; , the contents of the Utf-8 as GBK sent out, so there is garbled
For this you need
$queryString = Iconv (' utf-8 ', ' GBK ', $_post[' queryString ');
Turn the data from Ajax to code
Because you have the header (' CONTENT-TYPE:TEXT/HTML;CHARSET=GBK ');
So Ajax will interpret the returned content as GBK
But Ajax always sends data out of Utf-8.
So you $queryString = $_post[' queryString ');
Get the data that is UTF-8 encoded when you echo $sql; , the contents of the Utf-8 as GBK sent out, so there is garbled
For this you need
$queryString = Iconv (' utf-8 ', ' GBK ', $_post[' queryString ');
Turn the data from Ajax to code
Thank xuzuning once again to solve my problem!