A simple way to do this in PHP is using a loop to wait for an event, and
return if and when it does. Otherwise the connection times out, and the
client (web browser using XMLHttpRequest) reconnects. A really simple
demonstration can be seen by just doing an ajax request to a php script that
sleep()'s. Here is an example.

<?php
    if($_REQUEST['wait'])
    {
        sleep($_REQUEST['wait']);
        echo time();
        die();
    }
?>
<html>
    <head>
        <script src="/js/jquery.js" type="text/javascript"></script>
        <script>
            jQuery(function()
            {
                $('input#hurumph').click(function()
                {
                    $.ajax(
                    {
                        url: 'index.php?wait=' + $('#in').val(),
                        success: function(sReturn)
                        {
                            $('span#time').html(sReturn);
                        }
                    });
                });
            });
        </script>
    </head>

    <body>
        What time is it in&#160;<input id="in"/>&#160;seconds&#160;<input
type="button" value="?" id="hurumph"/>
        <br/>
        ?:&#160;<span id="time"/>
    </body>
</html>

Just takes a simple input and wait the given amount of time. You can see
from this that you could easily wait for any other sort of event. Like
another user making and update. At that the point the connection get closed,
and the client just restarts it.


On Jan 6, 2008 3:56 PM, coughlinsmyalias <[EMAIL PROTECTED]> wrote:

>
> Hey all, i have been researching googling and many other ways to try
> to find out how to make my site as close to "live" as I can.
>
> I read this by John: http://ejohn.org/blog/streaming-http-server-push/
> but am still kind of confused. My site is:
>
> http://rksdesignstudios.com/magnet/
>
> - Drag a word
> - Add a word
> - Delete
>
> And many features to come, etc. I want to make it like you can seeo
> ther changes being made..stuff being dragged, any idea how to do this?
> I have been STUMPED on this.
>
> Thanks!
> Ryan
>



-- 
http://morglog.alleycatracing.com
Lets make up more accronyms!

http://www.alleycatracing.com
LTABOTIIOFR! ROFL! ROFL! ROFL!
Upcoming alley cats, reviews, touring logs, and a general congregation of
bike nerdity.

Reply via email to