programmer12 0 Junior Poster in Training

Hi,

I am trying to create a jquery fadeIn from an external file. I am using AJAX and PHP (see below) 1st snippet is the notify.php file. 2nd snippet is the external file called random.php

My question is: Where and How should I add in the Jquery to perform this action (making the new changes/content fadeIn)?

-Thanks in advance!

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>

    <script src="jquery.js" type="text/javascript"></script>  


        <title>Ajax</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

        <script type="text/javascript">

            function Ajax()
            {
                var
                    $http,
                    $self = arguments.callee;

                if (window.XMLHttpRequest) {
                    $http = new XMLHttpRequest();
                } else if (window.ActiveXObject) {
                    try {
                        $http = new ActiveXObject('Msxml2.XMLHTTP');
                    } catch(e) {
                        $http = new ActiveXObject('Microsoft.XMLHTTP');
                    }
                }

                if ($http) {
                    $http.onreadystatechange = function()
                    {
                        if (/4|^complete$/.test($http.readyState)) {
                            document.getElementById('ReloadThis').innerHTML = $http.responseText;
                            setTimeout(function(){$self();}, 10000);
                        }
                    };
                    $http.open('GET', 'random.php', true);
                    $http.send(null);

                }


            }

        </script>

    </head>
    <body>

        <script type="text/javascript">
            setTimeout(function() {Ajax();}, 0);
        </script>
        <div id="ReloadThis">

        </div>
    </body>
</html>





<?php 

    //Connection Variables
    $hostname = "localhost";
    $username = "root";
    $password = "";
    $database = "test";

    //Connect to Database
    $connect = mysql_connect($hostname, $username, $password);
    mysql_select_db($database, $connect);

    //Today's Date and Time
    $now_date = date("Y-m-d H:i:s");

    //Time and Date 10 seconds ago
    $ten_secs_ago = date("Y-m-d H:i:s", strtotime("-10sec", strtotime($now_date)));
    echo $ten_secs_ago;

    // convert a date into a string that tells how long 
// ago that date was.... eg: 2 days ago, 3 minutes ago.
FUNCTION ago($d) {
     $c = GETDATE();
     $p = ARRAY('year', 'mon', 'mday', 'hours', 'minutes', 'seconds');
     $display = ARRAY('year', 'month', 'day', 'hour', 'minute', 'second');
     $factor = ARRAY(0, 12, 30, 24, 60, 60);
     $d = datetoarr($d);
     FOR ($w = 0; $w < 6; $w++) {
          IF ($w > 0) {
               $c[$p[$w]] += $c[$p[$w-1]] * $factor[$w];
               $d[$p[$w]] += $d[$p[$w-1]] * $factor[$w];
          }
          IF ($c[$p[$w]] - $d[$p[$w]] > 1) { 
               RETURN ($c[$p[$w]] - $d[$p[$w]]).' '.$display[$w].'s ago';
          }
     }
     RETURN '';
}

// you can replace this if need be. This converts the dates 
// returned from a mysql date string into an array object similar 
// to that returned by getdate().
FUNCTION datetoarr($d) {
     PREG_MATCH("/([0-9]{4})(\\-)([0-9]{2})(\\-)([0-9]{2}) ([0-9]{2})(\\:)([0-9]{2})(\\:)([0-9]{2})/", $d, $matches);
    RETURN ARRAY( 
          'seconds' => $matches[10], 
          'minutes' => $matches[8], 
          'hours' => $matches[6],  
          'mday' => $matches[5], 
          'mon' => $matches[3],  
          'year' => $matches[1], 
     );
}


    //Check database to see if anything was added between todays date and ten seconds ago
    $status_check = mysql_query("SELECT * FROM update_status ORDER BY date DESC");
    while($s = mysql_fetch_assoc($status_check))
    {
         $t = $s['date'];
        $time_ago = ago($t);
        if($s['date'] >= $ten_secs_ago)
        {
            echo '<div id="new" style=" width:230px; padding:5px;background:#eeeeee; border-bottom:#cccccc 1px solid;">';
            echo $s['text'];
            echo '<p align="right">'.$time_ago.'</p>';
            echo '</div>';
        }
        else
        {
            echo '<div style="width:230px; padding:5px; border-bottom:#cccccc 1px solid;">'.$s['text'].'<p style="color:#666666; "        align="right">'.$time_ago.'</p></div>';
        }
    }


?>