PHP how to update page from handler

How can I refresh a page using PHP?
It means that during some action, refresh the page remotely, not the one on which the action is performed.


Answer 1, authority 100%

I would do it like this

1.       Ajax     .
2.      Ajax     

Answer 2

I have an implementation example – loading new requests:

$(document).ready(function(){
    setInterval('show()', 60000); // 1 minute
    show();
    blink(600000, 1000)
});
function show()
{
   $.ajax({
       url: "/ajax/",
       type: 'POST',
       cache: false,
       success: function(html){
           $("#tickets_fieldlist").html(html);
       }
   });
}
function blink(time, interval){
    var timer = window.setInterval(function(){
        $(".blink").css("opacity", "0.01");
        window.setTimeout(function(){
            $(".blink").css("opacity", "1");
        }, 300);
    }, interval);
    window.setTimeout(function(){clearInterval(timer);}, time);
}

When a document is loaded with a delay, show() is called, the blink() function makes the element in the new ticket (indicated by a light there) blink when the ticket is new.


Answer 3

Look towards Comet. Or Node.js. By its very nature, http works in response to a request from the client (=browser), i.e. if the user himself did not initiate a page refresh with a request to the server for data, then nothing will happen. You can “pound” with requests to the server at intervals asking if there have been changes or open a tunnel and wait for a response from the server, which, in fact, is what Comet does.

P.S. Knowledgeable people, if not right – correct me.

Leave a reply

Please enter your comment!
Please enter your name here