基于php返回值的实时jquery弹出窗口

Im having a php program that will calculate the time difference and return the value in minutes.

for the message popup i use jGrowl

so what i would like to do is get the return value and if its less than 30 minutes display the jquery message.

and most importantly it should be running live. so if a user is in a page without navigating or refreshing, if the time is less than 30 minutes the popup should appear real-time.

can someone please suggest me how to use the return value to achieve the above requirement?

Below if the code that im using to calcutale the time differnce

    function time($dbtime, $currtime)
    {
        //format year-month-day hour:min:secs
        $current = strtotime($currtime);
        $indb = strtotime($dbtime);
        $minits =  round(abs($current - $indb) / 60,2);

        return $minits;
    }

currently im poping up only the messages on date

<script type="text/javascript">

        (function($){

            $(document).ready(function(){

                // jGrowl
                if ($.fn.jGrowl) {
                    // This value can be true, false or a function to be used as a callback when the closer is clciked
                            $.jGrowl.defaults.closer = function() {
                                console.log("Closing everything!", this);
                            };

                            // A callback for logging notifications.
                            $.jGrowl.defaults.log = function(e,m,o) {
                                $('#logs').append("<div><strong>#" + $(e).attr('id') + "</strong> <em>" + (new Date()).getTime() + "</em>: " + m + " (" + o.theme + ")</div>")
                            }               


                            <?php foreach ($dailies as $daily):?>
                            $.jGrowl("<?php echo $daily['calendars'][0]['Title']?>", { header: 'At <?php echo $daily['calendars'][0]['Start'];?>', sticky: true });


                            <?php endforeach;?>

                            $.jGrowl.defaults.closerTemplate = '<div>hide everything</div>';


                }

            });
        })(jQuery);

    </script>

Have a php script that takes passed parameters, in this case the two times. Write the script to return the results as JSON. This is the part I assume you already have done. If you don't have the results returning as as JSON string you can read up on JSON here.

In your webpage, make the request with javascript & ajax. Basically, when the user clicks a button, send the info asynchronously to your php script, and when the response is received display the inf to the user. You can read up on Javascript & Ajax here.