本人用JQUERY的$.get()方法向指定页面传参数,可遇到中文就会乱码,不知道是什么回事?网上找了很多方法都不行,哪位大侠知道的,请指教

解决方案 »

  1.   

    将参数 encodeURIComponent() 编码试试
      

  2.   

    encodeURIcomponent(string).replace(/%20/g, "+");得urlencode一下再放到URL里, 另外你的这个JQUERY的页面说明charset了吗,和GET的页面的编码一致吗。
      

  3.   

    一致的,都是<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    在哪里用encodeURIcomponent(string).replace(/%20/g, "+");呢?
      

  4.   


    把中文GET参数传给encodeURIcomponent(string).replace(/%20/g, "+")的string,结果拼接到Query部分。
      

  5.   

    php和html的文件编码格式一致吗
      

  6.   

    jquery代码是这样的:  
    $.get('get.php', { name: bookcaseName }, function(data) {
                    alert(unescape(data));
                });
    PHP页面代码:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    </head><body>
    <?php  $name=$_GET['name'];
    /*$name = iconv("gbk","utf-8",$name);  */
    $name=mb_convert_encoding($name, "UTF-8", "gb2312");if($name=='123')
    {
    echo 'username already exist!';}else{ echo escape($name);  
    }
    ?>
    </body>
    </html>
      

  7.   

    html,php都搞成utf-8.
    html端,encodeURIComponent(bookcaseName )就可以了
      

  8.   

    在js或jquery中,使用escape 和unescape 解决乱码是常用的!都测试一下吧
      

  9.   

    换成 utf-8格式的,记住是所有的,而且是utf-8无BOM格式的
      

  10.   

    所有文件编码都换成utf-8的吧。。这样就减少很多问题了。