最近,我更改了一些要通过ajax显示的页面,但对于为什么utf8编码现在在框内显示一个问号却不知道,我有些困惑。
举个例子。最初的页面是index.php。charset已显式设置为utf8,位于中
。然后我用php查询数据库这是原始的index.php页面:
Title hereData displayed via php was simply a select statement that output the HTML.
?>
但是,当我进行更改以添加通过ajax填充“ main_container”的菜单时,所有utf8编码均停止工作。这是新的代码:
Title here“ display_html()”函数将调用javascript页面,该页面使用jquery
ajax调用来检索存储在php页面中的html,然后将html放入id为“
main_container”的div中。我将jQuery中的字符集设置为utf8,例如:
$.ajax({
async: false,
type: "GET",
url: url,
contentType: "charset=utf-8",
success: function(data)
{
$("#main_container").html(data);
}
});
我究竟做错了什么?