当php文件嵌入jquery时奇怪的字符

时间:2012-12-06 19:06:33

标签: php jquery character

我遇到了通过jquery显示php文件内容的问题。内容为http://pastebin.com/V8RxqPe3

这是我的问题: 如果该内容位于mysql数据库中,则content.php文件查询以获取该内容并回显它。当我打开localhost / content.php时,一切都很好。但如果我通过jquery(下面)显示内容,我会得到一些黑色问号(奇怪的字符)。

<div id="results"></div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
     $(function() {
         $.get('http://localhost/content.php', function(data) {
             $('#results').html(data);
         });
     });
</script>

当我用'手动替换所有\'并将整个内容放入content.php文件中的变量时,然后通过上面相同的jquery脚本回显该变量,一切都很好

有没有人知道如何解决这个问题?,因为我想在上面的jquery脚本中显示我的数据库中有很多这样的内容。

谢谢!

1 个答案:

答案 0 :(得分:1)

你的页面和mysql连接是否设置为utf-8?