我正在尝试将我的静态 php 页面更改为 ajax。老实说,我没有太多关于它的信息。
我的问题是:当我将内容加载到 div 中时,我的旧 php 版本工作正常,但是当我使用 ajax 将内容放入 div 时(我实际上发现,你可以在下面找到)意大利字符变成了。
我浏览了其他一些类似的问题,但找不到有用的信息。
我使用标题:
我的 sql 编码是 utf_unicode_ci
而且我还意识到,当我将 php 标头添加为 utf 8 时,我的 php 版本字符也坏了。
我提出任何建议
谢谢
<script>
function createRequestObject() 
{
    var returnObj = false;
    if(window.XMLHttpRequest) {
        returnObj = new XMLHttpRequest();
    } else if(window.ActiveXObject) {
        try {
            returnObj = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
            try {
            returnObj = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e) {}
            }
    }
    return returnObj;
}
var http = createRequestObject();
var target;
// This is the function to call, give it the script file you want to run and
// the div you want it to output to.
function sendRequest(scriptFile, targetElement)
{   
    target = targetElement;
    try{
    http.open('get', scriptFile, true);
        }
    catch (e){
    document.getElementById(target).innerHTML = e;
    return;
    }
    http.onreadystatechange = handleResponse;
    http.send();    
}
function handleResponse()
{   
    if(http.readyState == 4) {      
    try{
        var strResponse = http.responseText;
        document.getElementById(target).innerHTML = strResponse;
        } catch (e){
        document.getElementById(target).innerHTML = e;
        }   
    }
}
</script>