Reputation: 11
I created ajax to get start time and end time from another page and setInterval for this function every second like this.
setInterval(function () {
CheckTime()
}, 1000);
function CheckTime() {
$.ajax({
url: "Get_TIme.php",
success: function (result) {
var time = result.split('|');
var start_time = time[0];
var end_time = time[1];
var getTime = new Date();
var currentHours = getTime.getHours();
var currentMinutes = getTime.getMinutes();
var currentTime = currentHours + ":" + currentMinutes;
if ((currentTime == start_time) || (currentTime == end_time)) {
$('#first').load('demo.php #first'); //reload div
}
}
});
At first time when current time = start time
, <div>
can refresh itself. But when current time = end time
, <div>
doesn't reload itself. I don't what happen on this code. But I replace alert before if((currentTime==start_time)||(currentTime==end_time))
like this:
alert("something");
if((currentTime==start_time)||(currentTime==end_time))
{
$('#first').load('demo.php #first'); //reload div
}
<div>
can reload itself when current time = end time
. Anyone can suggest me what happen on my code.
Upvotes: 0
Views: 282
Reputation: 3559
Try this:
if((currentTime==start_time)||(currentTime==end_time))
{
$('#first').load('demo.php'); //reload div
}
if you want show #first use following;
$(document).ready(function(){
$("#first").css("class","active");
}
Upvotes: 0