Reputation: 5403
I have the following function which updates a time_remaining span on the page.
function update() {
$.ajax({
type: 'POST',
url: 'check_time.php',
data: 'checktime=true',
timeout: 2000,
success: function(data) {
$(".time_remaining").html(data);
window.setTimeout(update, 2000);
var time=(html(data));
alert(time);
if(time<=0)
{
$(".time_remaining").html("now");
}
else
{
$(".time_remaining").html(data);
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
$("#notice_div").html('Timeout contacting server..');
window.setTimeout(update, 60000);
}
});
};
My only problem is this line:
var time=(html(data));
It simply does not define the variable correctly. Any pointers?
Upvotes: 0
Views: 293
Reputation: 6030
(html(data)) is not a defined method used in this fasion.
var time = $(".time_remaining").html();
or
var time = data;
Upvotes: 1