Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在特定时间刷新Div_Php_Jquery_Html_Refresh - Fatal编程技术网

Php 在特定时间刷新Div

Php 在特定时间刷新Div,php,jquery,html,refresh,Php,Jquery,Html,Refresh,好的,我正在创建一个广播播放机,基本上我需要标题、内容分区、下一个节目分区在特定时间刷新,例如上午9点到下午12点。我有JQuery代码在特定时间刷新页面,但这不是我想要的。有什么想法吗 代码: 然后通过在页面上插入以下内容来调用refreshAt函数 <script type="text/javascript">refreshAt(04,30,0);</script> //page refreshes at 4:30am. refreshAt(04,30,0)//页面

好的,我正在创建一个广播播放机,基本上我需要标题、内容分区、下一个节目分区在特定时间刷新,例如上午9点到下午12点。我有JQuery代码在特定时间刷新页面,但这不是我想要的。有什么想法吗

代码:

然后通过在页面上插入以下内容来调用refreshAt函数

<script type="text/javascript">refreshAt(04,30,0);</script> //page refreshes at 4:30am.
refreshAt(04,30,0)//页面在凌晨4:30刷新。
因此,这将刷新整个页面。我只需要刷新标题和两个div。 我需要在代码中添加/更改什么。

您可以尝试以下方法:

setTimeout(function() { 
    document.title = "new title";
    $(".divname").text("new div text");
}, timeout);
您可以尝试以下方法:

setTimeout(function() { 
    document.title = "new title";
    $(".divname").text("new div text");
}, timeout);

您可以看看jQuery的方法

通过使用is,您可以加载div的内容

    setTimeout(function() { 
      $("#youfirstdivid").load("url1"); 
       $("#youseconddivid").load("url2");

      $('title').text("new title"); 
   }, timeout);
别忘了把代码包装在里面

$(function(){
  //you code goes here

});

如果你想以固定的时间间隔刷新它,那么你可以使用setInterval而不是setTimeout,你可以看看jQuery的方法

通过使用is,您可以加载div的内容

    setTimeout(function() { 
      $("#youfirstdivid").load("url1"); 
       $("#youseconddivid").load("url2");

      $('title').text("new title"); 
   }, timeout);
别忘了把代码包装在里面

$(function(){
  //you code goes here

});

如果您想以固定的时间间隔刷新,则可以使用setInterval而不是setTimeout,请尝试以下代码:

setTimeout(function(){
        $('#divid').load("pageurl #divid" >*",function(){

        });
  }, 6000);

6秒后重新加载div。

请尝试以下代码:

setTimeout(function(){
        $('#divid').load("pageurl #divid" >*",function(){

        });
  }, 6000);

您的div将在6秒后重新加载。

这将在间隔时间过后调用当前URL,并重置您的
标题和
div
内容

你必须这样写:

function refreshAt(hours, minutes, seconds) {
   var now = new Date();
   var then = new Date();

   if(now.getHours() > hours || (now.getHours() == hours && now.getMinutes() > minutes) || now.getHours() == hours && now.getMinutes() == minutes && now.getSeconds() >=  seconds) {
           then.setDate(now.getDate() + 1);
   }
   then.setHours(hours);
   then.setMinutes(minutes);
   then.setSeconds(seconds);

   var timeout = (then.getTime() - now.getTime());
   setTimeout(function() {
      $.get( window.location.pathname, function( data ) {
             $('title') = $(data).filter('title').text();
             $('.DIV_CLASS') = $(data).filter('.DIV_CLASS').html();
             alert( "Load was performed." );
     });
   }, timeout);
}

注意:此脚本使用jQuery,因此请包含最新的jQuery库。

这将在间隔时间过后调用当前URL,并重置您的
标题和
div
内容

你必须这样写:

function refreshAt(hours, minutes, seconds) {
   var now = new Date();
   var then = new Date();

   if(now.getHours() > hours || (now.getHours() == hours && now.getMinutes() > minutes) || now.getHours() == hours && now.getMinutes() == minutes && now.getSeconds() >=  seconds) {
           then.setDate(now.getDate() + 1);
   }
   then.setHours(hours);
   then.setMinutes(minutes);
   then.setSeconds(seconds);

   var timeout = (then.getTime() - now.getTime());
   setTimeout(function() {
      $.get( window.location.pathname, function( data ) {
             $('title') = $(data).filter('title').text();
             $('.DIV_CLASS') = $(data).filter('.DIV_CLASS').html();
             alert( "Load was performed." );
     });
   }, timeout);
}


注意:此脚本使用jQuery,因此请包含最新的jQuery库。

刷新div的主要逻辑是什么?您是否尝试刷新以加载div中的一些数据?Hello@Veerendra,其背后的逻辑就像主持人正在广播一样,例如“John Smith-09:00”当下一个演讲者在12:00播出时,我希望该节目改为“Peter Smith-12:00”,而听众无需刷新。刷新该节目的主要逻辑是什么?您是否试图刷新以加载节目中的一些数据?Hello@Veerendra,其背后的逻辑是,就像演讲者正在播出一样,例如“John Smith-09:00”当下一位演讲者12:00播出时,我希望节目切换到“Peter Smith-12:00”,而听众无需刷新。谢谢你的回答,但这不是我想要的。谢谢你的回答,但这不是我想要的。谢谢你的回答,这与我所追求的类似,但我希望在特定时间刷新,例如12:00pm,然后在15:0pm再次刷新。脚本必须能够从侦听器计算机获取时间,以便它准确地知道何时刷新。感谢您的回答,这与我所追求的类似,但我希望在特定时间刷新,例如12:00pm,然后在15:0pm再次刷新。脚本必须能够从侦听器计算机获取时间,以便它准确地知道何时刷新。感谢您的回答,我将尝试此操作。是否可以使用列表中基于时间的信息刷新div?比如说,我有一张名单,每个人都有一段时间在广播中。我需要脚本根据时间选择一个人并在div中显示。你知道我的意思吗?有可能吗?@user301524你的意思是获取用户的系统时间并根据它工作。是的,这正是我的意思:)@Julian请回答这个问题:谢谢你的回答,我会尝试一下。有可能让它根据时间使用列表中的信息刷新div吗?比如说,我有一张名单,每个人都有一段时间在广播中。我需要脚本根据时间选择一个人并在div中显示。你知道我的意思吗?可能吗?@user301524你的意思是获取用户的系统时间并根据它工作。是的,这正是我的意思:)@Julian请回答这个问题:谢谢你的回答,但这不是我想要的。我需要在某些时间刷新这些div,比如下午4点到8点。谢谢你的回答,但这不是我想要的。我需要在某些时间刷新这些div,比如下午4点到8点。