倒計時

效果:


文件1:LongDay.php

<!DOCTYPE html PUBLIC>
<!--[if IE 7]>         <html class="no-js ie7"> <![endif]-->
<!--[if IE 8]>         <html class="no-js ie8"> <![endif]-->
<!--[if IE 9]>         <html class="no-js ie9"> <![endif]-->
<!--[if gt IE 9]><!--> <html class="no-js"> <!--<![endif]-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>新聞點評功能</title>
    <style>
    body {height:100px;font-size:16px;color:#048bcc;margin:5%;}
    a {text-decoration:none;}
    .divFrame {width:572px;border:solid 1px #666;background-color:#fafcff:}
    .divFrame .divTitle {padding:5px;background-color:#eee}
    .divFrame .divTitle span{padding:2px;padding-top:5px;font-family:黑體;font-size:14px;}
    .divFrame .divContent {padding:5px}
    .divFrame .divContent .clsShow {font-size:16px;}
    .divFrame .divContent .clsShow .ShowBottom{text-align:right;font-size:12px;color:#555;}
    .divFrame .divSubmit{padding:20px;}
    .divFrame .divSubmit .SubContent .SubBtn{padding-top:10px;padding-bottom:12px;font-size:12px;color:#555;font-weight:bold;}
    .btn {border:#666 1px solid;width:80px;}
    .txt {width:525px;margin-bottom:5px;margin-top:5px;}
    .clsError {margin-bottom:5px;margin-top:5px;}
    .clsTip {position:absolute;width:160px;text-align:center;font-size:13px;border:solid 1px #cc3300;padding:2px;margin-bottom:5px;background-color:#ffe0a3;}
    </style>
    <script src="js/jquery-1.8.3.min.js"></script>
    <script type="text/javascript">
    $(function(){
        $("#divMsg").ajaxStart(function(){
            $(this).html("正在發送數據請求......").show(); //顯示元素
        })
        $("#divMsg").ajaxStop(function(){
            $(this).html("數據處理完成。").hide(); //顯示後再隱藏
        })
        //初始化點評數據
        LoadData();
        $("#Button1").click(function(){
            var strName = $("#txtName").val();
            var strContent = $("#txtContent").val();
            $.ajax({
                type:"GET",
                url:"addData.php",
                data:{name:strName,content:strContent},
                dataType:"html",
                success:function(msg){
                    alert(msg);
                    LoadData();
                    $("#txtName").val("");
                    $("#txtContent").val("");
                }
            })
        })
        //動態加載XML格式的點評數據
        function LoadData(){
            $.ajax({
                type:"GET",
                url:"CommentData.xml", //請求XML格式數據
                dataType:"xml",
                cache:false,
                success:function(data){
                    $(".divContent").empty();  //先清空標記中的內容
                    var strHTML = "";  //初始化保存內容變量
                    //如果沒有找到數據
                    if ($(data).find("Data").length == 0){
                        strHTML = "<div style='text-align:center'>目前還沒有找到點評數據!</div>";
                    }
                    //遍歷獲取的數據
                    $(data).find("Data").each(function(){
                        var $strUser = $(this);
                        strHTML += "<div class='clsShow'>";
                        strHTML += "<div class='ShowTitle'>網友遊俠  <a href=''>" + $strUser.find("name").text() +"</a></div>";
                        strHTML += "<div class='ShowContent'>" + $strUser.find("content").text() +"</div>";
                        strHTML += "<div class='ShowBottom'>發送時間  " + $strUser.find("date").text() +"</div>";
                        strHTML += "</div>";
                    })
                    $(".divContent").html(strHTML); //顯示處理後的數據
                }
            })
        }
    })
   
    </script>
</head>
<body>
  <div class="divFrame">
    <div class="divTitle">
        <span>最新點評</span>    
    </div>
    <div class="divContent">
    </div>
    <div class="divDay" style="text-align:center;">
    <?php
        $d1=strtotime("January 1 2016");
        $d2=ceil(($d1-time())/60/60/24);
        date_default_timezone_set("Asia/Shanghai"); //設置時區
        echo "今天是:".date("Y-m-d")." ".date("l")."<br/>";
        echo "現在時間是: " . date("h:i:sa")."<br/>";
        echo "距離2016年新年還有:" . $d2 ." 天"."<br/>";
    ?>
    </div>
    <div class="divSubmit">
        <div class="SubTitle">發表評論  
            <span id="divMsg" class="clsTip">正在發送數據請求......</span>
        </div>
        <div class="SubContent">
            <textarea id="txtContent" rows="6" class="txt"></textarea>
            <div class="SubBtn">
                <span style="float:left">用戶名:<input id="txtName" type="text" class="txtName" /></span>
                <span style="float:right"><input id="Button1" type="button" value="發表" class="btn" /></span>
            </div>
        </div>
    </div>  
  </div>
</body>
</html>



文件2:addData.php
文件3:<span style="font-family: Arial, Helvetica, sans-serif;">CommentData.xml  動態創建</span>


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章