php文件中有两个重要参数:
$szamol
这指定等待的秒数。 (需要从当前时间开始): 当时间到时,调用这些函数:
$jatek = new jatek( $_SESSION['id'] );
$jatek->epuletkesz();
我知道我不能在PHP倒计时中做到这一点,但我不知道将php中的两个参数传递给javascript函数。
例如,javascript的setTimeout()函数可能不错,但我不能把这两个参数传给php。
最佳答案
您可以使用 ajax 请求,例如:
var szamol = 6000; // 6 seconds
var timer = setTimeout(function(){
$.post('/path/to/my/php/file.php', {}, function(data) {
// do something with the response
}, 'json');
}, szamol);
关于javascript - 带有 php 元素的 javascript 计时器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29796447/