$("#enter_q").click(function(){
$.ajax({
url: '../page.php',
type: 'post',
data: {'enter_q': 'true'},
success: function(data, status){
if (data == "ok"){
$("#timer").innerHTML = '<p>TIMER IS RUNNING</p>';
}
}, error: function(xhr, desc, err){
console.log(xhr);
conso.log("Details: " + desc + "\nError: " + err);
}
})
$("#leave_q").click(function(){
$.ajax({
url: '../page.php',
type: 'post',
data: {'leave_q': 'true'},
success: function(data, status){
if (data == "ok"){
$("#timer").innerHTML = '<p>TIMER HAS STOPPED</p>';
}
}, error: function(xhr, desc, err){
console.log(xhr);
conso.log("Details: " + desc + "\nError: " + err);
}
})
这只是将文本从开始更改为ajax中的计数器。
答案 0 :(得分:0)
在您的情况下,您应该使用setInterval js-function
var intervalID = setInterval(function() { 'make some operatins here' }, 1000)
如果您想停止计时器,请致电
clearInterval(intervalID);