designaire
asked on
send to Ajax when timer ends
This timer works fine but I need to send the results to Ajax when it is done. This seems to work in chrome unless the cache is cleared or it plays the first few times. I'm wondering if there is another way to send it to Ajax when it is done. I don't know how to tell when it's done. Somebody helped me with this code and I'm very new at code.
http://squareonemeditation.com/webapp/meditatetest.php
http://squareonemeditation.com/webapp/meditatetest.php
function drawTimer(percent){
$('div.timer').html('<div id="slice"'+(percent > 50?' class="gt50"':'')+'><div class="pie"></div>'+(percent > 50?'<div class="pie fill"></div>':'')+'</div>');
var deg = 360/100*percent;
$('#slice .pie').css({
'-moz-transform':'rotate('+deg+'deg)',
'-webkit-transform':'rotate('+deg+'deg)',
'-o-transform':'rotate('+deg+'deg)',
'transform':'rotate('+deg+'deg)'
});
$('.percent').html(Math.round(percent)+'%');
}
$(stopWatch = function() {
if(percent >=100){
drawTimer(100);
clearInterval(timer);
$.ajax({
url: "postmeditate.php",
type : "POST",
data: { length: length, userid: userid},
})
.success(function (response){
location.href = "tracking.php";
})
.error(function (e){
});
}else{
percent += (timerSeconds/minutes)
drawTimer(percent);
counter++;
}
});
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I can't thak you enough
ASKER