How to call a PHP class method from a JavaScript function
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/7165395/call-php-function-from-javascript">Call php function from javascript</a>  </p>
</blockquote>



<p>I understand that php is server side and JavaScript is client side. But I would like to know how to run a PHP method when a JavaScript function is called. Below is my code, I know the error is  but how can I perform the php method?</p>

<pre><code> &lt;script type="text/javascript"&gt;
            function toggle()
            {
                var ele = document.getElementById("addCatTextBox");
                var text = document.getElementById("addCatButtonText");
                if(ele.style.display == "block") {
                        ele.style.display = "block";
                    text.innerHTML = "Save category";
                    &lt;?php Category::addCategory($inCatName)?&gt;
                }
                else {
                    ele.style.display = "none";
                    text.innerHTML = "Add new category";
                }
            } 
    &lt;/script&gt;
</code></pre>

<p>Thanks for your help.</p>
