Help solve the problem: it is necessary to display events (text, numbers, or a graph) at a given time interval. An approximate solution can be seen in the Rambler, TV program section.

    4 answers 4

    For this you need to use AJAX.

    I will not explain here (a lot of what is needed), just look here you can also here

    • There are ways to use only PHP. But not for your case. The example for pure PHP works only for chats, logs, etc. where you do not need to erase page elements. - Sergey
    function xmlHttp(){ var xmlhttp; try{ xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch(e){ try{ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch(E){ xmlhttp = false; } } if(!xmlhttp&&typeof XMLHttpRequest!='undefined'){ xmlhttp=new XMLHttpRequest(); } return xmlhttp; } function ajax(href, callback, method, data) { callback = callback || null; method = method || 'get'; data = data || null; var x = xmlHttp(); x.onreadystatechange = function(){ if(x.readyState == 4 && x.status == 200) if(callback) callback.apply(x.responseText); };, href, true); if(method == 'post') x.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); x.send(data); } setTimeout(function(){ajax("news.php", function(text){ document.getElementById('news').innerHTML = text; })}, 60*1000); 

    That's about it (the code is not tested). And news.php should give already ready code for insertion into the news block, that is, without html, body and other husks.

      You can also use jQuery type libraries, they greatly simplify working with Ajax

        There is no one PHP to do, on the client side you need to use javascript and Ajax.

        More specifically: setInterval () .

        By Ajax a bunch of information. The easiest way is to use it from a thread of the framework.