ajax数据库请求没有返回德语字符?

时间:2013-08-03 18:25:58

标签: php ajax database char set

我从中获取数据的表格在“Latin_1”中,但是当返回数据时,带有德语字符的字段将返回为空。 它为什么这样做? json编码会影响char集吗? 除此之外,我完全迷失了。

我看过你可以在php中设置字符集,但它已经设置正确并且表格中有特殊字符?

编辑//

这是我正在使用的代码 __php:

function getInfo($country){

    $rows = array();
    $query = "SELECT name,add1,add2,town,district,postcode FROM stockistsWorld WHERE country = '". mysql_escape_string($country) ."' LIMIT 4 ";
    //$query = "SELECT Name,add1 FROM stockistsUK LIMIT 10";
    $result = mysqli_query($this->conn, $query);
    /* numeric array */

    while($row = mysqli_fetch_array($result, MYSQLI_NUM)){

         $rows[] = $row;

        }

    return $rows;
}

这是ajax request_ _

function ajaxData(country){
//get data from database return into inf array 
var infArray = new Array();
 $.ajax({
        type: 'POST',
        url: 'php/Maps.php',
        data: {country: country},
        success: function(data){
        infArray = JSON.parse(data);
        geoCodeClientSide(infArray);
        }           
    });

}

1 个答案:

答案 0 :(得分:1)

请将db / table的charset设置为utf-8。

谢谢, 新