2014-01-25 12:27
浏览 38


Hi all apologies if this is an easy solution, I am creating an test application and require that a timer is started when the user clicks on the test. I am however completely confused how to implement a counter for the application - and how to trigger an action when the timer has reached 0.

I have found implementations of JS timers/countdowns:

PHP Timer wait 30 seconds then run a command

PHP when countdown runs out

and a php timer:

Start and stop a timer PHP

I was hoping that someone could help me with an example of a PHP timer that triggers an action when it has reached 0 for example - redirecting to another page.

Many thanks in advance - please have patience, I am a total beginner

图片转代码服务由CSDN问答提供 功能建议

如果这是一个简单的解决方案,我很抱歉,我正在创建一个测试应用程序并要求在启动时启动计时器 用户点击测试。 但是我完全混淆了如何为应用程序实现一个计数器 - 以及如何在计时器达到0时触发一个动作。


PHP计时器等待30秒 然后运行命令

PHP倒计时时 耗尽



我希望有人可以帮我一个PHP计时器的例子 例如,当它达到0时触发一个动作 - 重定向到另一个页面。

非常感谢提前 - 请耐心等待,我是一个初学者

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • doutao4938 2014-01-25 12:40

    Using JQuery:

    function runTimer(seconds, yourUrl) {
      setTimeout(function() {
      }, seconds * 1000;

    run it:

    runTimer(5, '');

    But it won't be possible to redirect to other page using ajax request.

    For redirecting use:

    function runTimerRedirect(seconds, yourUrl) {
      setTimeout(function() {
        window.location = yourUrl
      }, seconds * 1000;
    打赏 评论

相关推荐 更多相似问题