仅刷新当前日期的页面

时间:2017-11-05 05:34:33

标签: javascript php ajax refresh

我想只对当前日期进行自动页面刷新,而不是以前的日期。我使用了jquery datepicker。我在我的datepicker函数上设置当前日期。之前我使用meta标签进行自动刷新。但是它的工作是所有日期。当我打开链接然后我当前的日期报告显示。我使用PHP / MySQL,请给我解决方案     这是代码:

<script>
function showdate(str)
    {
        if (str=="")
            {
                document.getElementById("txtHint2").innerHTML="";
                return;
            } 
        if (window.XMLHttpRequest)
            {// code for IE7+, Firefox, Chrome, Opera, Safari
                xmlhttp=new XMLHttpRequest();
            }
        else
            {// code for IE6, IE5
                xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
                xmlhttp.onreadystatechange=function()
                    {
                        if (xmlhttp.readyState==4 && xmlhttp.status==200)
                            {
                                document.getElementById("txtHint2").innerHTML=xmlhttp.responseText;
                                document.getElementById("txtHintl").innerHTML="";
                            }
                        else  
                            {
                                document.getElementById("txtHintl").innerHTML='<img src="./images/loading.gif" style="padding:270px 0 0 440px;">';
                            }
                    }

                xmlhttp.open("GET","sfile.php?q="+str,true);
                xmlhttp.send();
                var today = new Date();
                var dd = today.getDate();

                var mm = today.getMonth()+1; 
                var yyyy = today.getFullYear();
                if(dd<10) 
                    {
                        dd='0'+dd;
                    } 

                if(mm<10) 
                    {
                         mm='0'+mm;
                    } 
                today = mm+'-'+dd+'-'+yyyy;
                //console.log(today);
                today = mm+'/'+dd+'/'+yyyy;
                //console.log(today);
                today = dd+'-'+mm+'-'+yyyy;
                //console.log(today);
                //today = dd+'/'+mm+'/'+yyyy;
                today = mm+'/'+dd+'/'+yyyy;
                //alert(today+d);
                if(today==str)
                    {
                        setInterval(function(){
                        window.location.reload();
                        }, 30000);
                    }
                if(today!==str)
                    {
                        var ref=setInterval(function(){
                        window.location.reload();
                        }, 100000);
                        clearInterval(ref);
                    }
            }
</script>

<!-- Calender Area -->
  <link rel="stylesheet" href="calendar/jquery.ui.all.css" type="text/css">
  <script src="js/old/jquery-1.6.4.min.js"></script>
  <script type="text/javascript" src="js/old/jquery.ui.core.min.js">      </script>
  <script type="text/javascript" src="js/old/jquery.ui.datepicker.min.js"></script>

<script type="text/javascript">
    $(document).ready(function()
     {
       var jQueryDatePicker1Opts =
      {
        dateFormat: 'yy-mm-dd',
        changeMonth: false,
        changeYear: false,
        showButtonPanel: false,
        showAnim: 'show'
     };
     $("#jQueryDatePicker1").datepicker(jQueryDatePicker1Opts);
     $("#jQueryDatePicker1").datepicker("setDate", "new Date()");
  });
</script>
<!-- End Calender area-->

<div class="wrapper row3">
    <div id="container">
        <div class="full_width clear">

    </div>
    <input type="text" id="jQueryDatePicker1" class="form-control" 

   name="Date" value="02/21/2013" onchange="showdate(this.value)">
   <br>
        <div id="txtHint2">
        </div>
        <div id="txtHintl">
    </div>
</div>
</div>

0 个答案:

没有答案