title: How to get UTF-8 format data through ajax
body: <p>Sorry if i am asking a silly question but i really need a solution for it.I am requesting for some data using ajax and the script is</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;script&gt;
  function loadXMLDoc()
  {
  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 &amp;&amp; xmlhttp.status==200)
      {
      document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
      }
    }
  $url='http://localhost/path/to/the/php/script';
  xmlhttp.open("GET",$url,true);
  xmlhttp.send();
  }
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;div id="myDiv"&gt;&lt;h2&gt;Let AJAX change this text&lt;/h2&gt;&lt;/div&gt;
  &lt;button type="button" onclick="loadXMLDoc()"&gt;Change Content&lt;/button&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>and this is my php script</p>
  
  <pre><code>&lt;?php 
  
  $sqlurl='/path/to/my/file';
  
   if(file_exists($sqlurl))
              {
                  $sqlitedata= file_get_contents($sqlurl);
  
         echo $sqlitedata;
              }
              else {
  
             echo 'the file is not available right now';
               } 
  ?&gt;
  </code></pre>
  
  <p>Now the problem is that the data in my file is in the <strong>UTF-8 format</strong> but when i try to get it through ajax then what i get is a series of <strong>question marks (??????)</strong> . How can i request for the data through ajax in the same format in which it originally exists.</p>