Search code examples
phpjqueryinternet-explorerencode

utf8 jquery and ie


hi i use this code for save text in database

function commenttext()
{
  var com=document.getElementById("commenttext").value;
  var xmlhttp;
  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("commentpalm").innerHTML=xmlhttp.responseText;
      }
  }
  xmlhttp.open("GET","func/comment.php?comtext="+com,true);
  xmlhttp.send();
  document.getElementById("commenttext").value="";
}

and when i see database field in mysql admin insteat of utf8 charecter ???? save . this broblem only foe ie and in firefox or chrome is good . i use for all page this code

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

and my encodin is uft8 without BOM .

this broblem is only for IE .


Solution

  • try:

    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    

    and add this line to your php.ini:

      default_charset = "utf-8"