title: Call PHP function using javascript ajax
body: <p>I want call a PHP function using Javascript(No Jquery)</p>
  
  <p>MY php function is </p>
  
  <pre><code>&lt;?php
  
  function helloworld() {
      echo 'Hello Ashish Srivastava';
  }
  ?&gt;
  </code></pre>
  
  <p>in hello.php file
  and my JavaScript is </p>
  
  <pre><code> &lt;script type="text/javascript"&gt;
              function getRoute() {
                  var hr = new XMLHttpRequest();
                  var url = "hello.php";
  
              hr.open("helloworld", url, true)
                  hr.setRequestHeader("Content-type", "application/x-www-from-urlencoded");
                  hr.onreadystatechange = function()
                  {
                      if (hr.readyState === 4 &amp;&amp; hr.status === 200)
                      {
                          var return_data = hr.responseText;
                          alert(return_data);
  
                      }
                  }
                  hr.send();
              }
          &lt;/script&gt;
  </code></pre>
  
  <p>and HTMl is </p>
  
  <pre><code>  &lt;input type="button" value="Hello" onclick="getRoute()"/&gt;
  </code></pre>
  
  <p>bt when i am calling this function i get nothing from server plz help  </p>