0

当我每 10 秒更新一次 div 的内容时,像 ÆØÅ 这样的特殊字符会变成问号。怎么了?这是我的代码:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
<script type="text/javascript">
var auto_refresh = setInterval(
function ()
{
   $('#chat').load('#chat');
}, 10000); // refresh every 10000 milliseconds

</script>
<body>
<div id="chat">
<div class="melding">
        <form action="chat.php?login=<?php echo $bruker; ?>" method="post">
        <table>
        <tr>
            <td><input style="width: 420px;" type="text" name="melding"><input style="
border: 1px solid white;
    background: #333;
    color: white;"type="submit" name="send" value="Send"></td>
        </tr>
        </table>
        </form>
<div style="color: white;">
    <?php
    $print = "SELECT * FROM chat WHERE (fra='$user' AND til='$bruker') OR (fra='$bruker' AND til='$user') ORDER BY id DESC LIMIT 100";

    $resultat = mysql_query($print);

    while($row = mysql_fetch_array($resultat)){ 
echo "<span class='red'>". nl2br(strip_tags($row['fra'])) .":</span> ". nl2br(strip_tags($row['melding'])) ."<br>";
}
?>
</div>
</div>

我的代码以 UTF-8 格式保存

4

1 回答 1

1

将此元标记添加到页面:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

它告诉浏览器您提供的字符是用 UTF-8 编码的。确保页面的其他内容也以 UTF-8 编码。

于 2012-12-08T16:48:49.237 回答