title: How to call php methods from js?
body: <p>I am working on project of Counter service where I need to control the flow the customers, each customer can have 5mins in the counter. On the other hand, the system should control 5 counters. </p>
  
  <p>Here is my attempt to solve the problem. Look at my MWE: </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code> //this is part of the code where I set the timer for each counter. 
  function increment() {
        if (running == 1) {
          setTimeout(function() {
            time++;
            var mins = Math.floor(time / 10 / 60);
            var secs = Math.floor(time / 10);
            var tenths = time % 10;
            if (mins == 5) {
              //after 5 mins is over the system should call php deQueue() method to dequeue the current and point out to next customer.
              document.getElementById("message").innerHTML = "Currently, Counters are available... Next Customer..."
              deQueue();
             //this is my php method.
              available();
            }
            document.getElementById("timer").innerHTML = mins + ":" + secs + ":" + tenths;
            increment();
          }, 100)
        }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>//And this is my php file.
  
  &lt;?php
         public function deQueue(){
        if (!$this-&gt;isEmpty()) {
         $this-&gt;front = ($this-&gt;front+1) %5;
         $this-&gt;size--;
        }else{
         echo "The Counter is empty! &lt;br&gt;";
        }
       }
      
      ?&gt;</code></pre>
  </div>
  </div>
  </p>