Jquery-ajax电子时钟

显示一个电子时钟:

2013-2-18 11:15:21

HTML代码:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<html>
    <head>
        <title>电子时钟</title>
        <script type="text/javascript" src="jquery/jquery.js"></script>
    </head>
    <body>
        <center>
            <h1></h1>
        </center>
        <script type="text/javascript">
            function getTime(){
                jQuery.ajax({
                    type: "post",
                    url: "time.php",
                    success:function(req){
                        $("h1").html(req);
                    }
                });
            }
            setInterval("getTime()",1000);
        </script>
    </body>
</html>
PHP代码:

<?php
    echo date("Y-m-d H:i:s");
?> 


你可能感兴趣的:(jquery)