title: How to call a JavaScript function from PHP?
body: <p>How to call a JavaScript function from PHP?</p>
  
  <pre><code>&lt;?php
  
    jsfunction();
    // or
    echo(jsfunction());
    // or
    // Anything else?
  </code></pre>
  
  <p>The following code is from <em>xyz.html</em> (on a button click) it calls a <code>wait()</code> in an external <em>xyz.js</em>. This <code>wait()</code> calls wait.php.</p>
  
  <pre><code>function wait() 
  {
    xmlhttp=GetXmlHttpObject();
    var url="wait.php"; \
    xmlhttp.onreadystatechange=statechanged; 
    xmlhttp.open("GET", url, true); 
    xmlhttp.send(null);
  } 
  
  function statechanged()
  { 
    if(xmlhttp.readyState==4) {
         document.getElementById("txt").innerHTML=xmlhttp.responseText;
    }
  }
  </code></pre>
  
  <p>and <em>wait.php</em></p>
  
  <pre><code>&lt;?php echo "&lt;script&gt; loadxml(); &lt;/script&gt;"; 
  </code></pre>
  
  <p>where <code>loadxml()</code> calls code from another PHP file the same way. </p>
  
  <p>The <code>loadxml()</code> is working fine otherwise, but it is not being called the way I want it.</p>