function next_second(){
var target = '1350840000';
var now = <?php echo time();?>;
alert(now);
}
$(function() {
setInterval(next_second, 1000);
});
the above alert function always returns same value. Am i doing something wrong?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The reason why it is returning the same value is because the value of your ‘now’ variable is generated by the time your page loads. It doesn’t make sense, because no matter how many times you execute the function, it would still return the same result/value.
You need to dynamically detect the current time but not on page load.
You can try the following script:
Thank you.