日期:2014-05-16  浏览次数:20301 次

jquery ajax 中文乱码怎么解决
两个网页都在同一文件夹下
index.html后会获取source.html代码,但是传回来的是乱码文字,两个网页都是gbk代码的,请问怎么解决这个问题?
index.html 代码如下:
HTML code

<html>
<head>
<title>load</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script type="text/javascript" src="http://localhost/leb/auto/js/jquery-latest.js"></script>
<script type="text/javascript">
    $(function(){
        $.ajax({
            url:"http://localhost/leb/jquery_ajax/source.html",
            cache:false,
            success:
                function(html){
                    $(".page").append(html);
                }
        });
    });
</script>
</head>
<body>
    <div class="page">
        <div class="head"></div>
        <div class="body"></div>
        <div class="foot"></div>
    </div>
</body>
</html>




source.html 代码如下:
HTML code

<body>
    <div class="page">
        <div class="head">头部</div>
        <div class="body">
            <p>身体</p>
        </div>
        <div class="foot">腿部</div>
    </div>
</body>





------解决方案--------------------
那你试下这样
JScript code

    $(function(){
        $.ajax({
            url:"http://localhost/leb/jquery_ajax/source.html",
            cache:false,
            dataType:"text", 
            success:
                function(html){
                    $(".page").html(html)
                }
        });
    });