xmlhttp.open获取无效字符

时间:2012-02-13 22:18:18

标签: mysql xmlhttprequest

我认为用

更改重音符号
$GLOBALS['normalizeChars'] = array(
    'Á'=>'Á', 'É'=>'É', 'Í'=>'Í', 'Ó'=>'Ó', 'Ú'=>'Ú', 'Ñ'=>'Ñ',
    'á'=>'á', 'é'=>'é', 'í'=>'í', 'ó'=>'ó', 'ú'=>'ú', 'ñ'=>'ñ'
);

和这个功能......

function MakeIt($toClean){
    return strtr($toClean, $GLOBALS['normalizeChars']);
}

...将帮助我将áéíóúñ替换为á等......

但我仍然遇到麻烦。

mainfile.php 调用get_data.php读取mySQL内容,该内容使用MakeIt();替换无效字符。如果我将get_data.php加载到浏览器中,则会正确替换字符,但是当它从 mainfile.php 加载时,它会返回无效的字符。

mainfile.php中

<script>
    function ShowData(str)
    {
    if (str=="")
      {
      document.getElementById("deal_rcpt").innerHTML="";
      return;
      }
    if (window.XMLHttpRequest)
      {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
      }
    else
      {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    xmlhttp.onreadystatechange=function()
      {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
        document.getElementById("deal_rcpt").innerHTML=xmlhttp.responseText;
        }
      }
    xmlhttp.open("GET","get_data.php?event="+str,true);
    xmlhttp.send();
    }
    ShowData(1) 
</script>
<div id="deal_rcpt"></div>

我认为xmlhttp与áéíóúñchars不兼容。

0 个答案:

没有答案