【发布时间】:2019-08-14 01:45:21
【问题描述】:
我正在从事柜台服务项目,我需要控制客户的流量,每个客户可以在柜台停留 5 分钟。另一方面,系统应控制 5 个计数器。
这是我解决问题的尝试。看看我的 MWE:
//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)
}
}
//And this is my php file.
<?php
public function deQueue(){
if (!$this->isEmpty()) {
$this->front = ($this->front+1) %5;
$this->size--;
}else{
echo "The Counter is empty! <br>";
}
}
?>
【问题讨论】:
-
您添加 ajax 标签的任何原因?
标签: javascript php arrays ajax queue