谁能解释为什么? 我在此守则:
<script>
$(document).ready(function()
{
refresh();
});
function refresh()
{
$.getJSON( getMessageDetails.php , function (json) {
//alert(json.length);
//$("#subject1").html(json[0].subject);
//$("#unique_code1").html(json[0].unique_code);
$("#msg_id").html(json[0].id);
$("#subject").html(json[0].subject);
$("#unique_code").html(json[0].unique_code);
if (json.length > 0 )
{
//alert(json.length);
window.location.reload();
}
else
{
//do something
}
});
window.setTimeout(refresh,30000);
}
</script>
What I am trying to do is if a new message came in json wont be empty so reload the page and if there are no new messages, keep on checking
What happens now is a new message comes in and the screen just starts flashing like crazy! It must do the reload once and then every 30 seconds check again. Any help please? Thank you.