定时任务(每两秒访问一次地址)

浏览582

<script type="text/javascript"> 

      var source = new EventSource("<{url  c='admin/main' a='test'}>"); 

      source.onmessage = function(event) { 

          console.log(222); 

      }; 

      source.onopen=function(e){ 

      console.log(e) 

     

 </script>




  function actionTest(){

      header('Content-Type: text/event-stream');

      header('Cache-Control: no-cache');

      $time = date('r');

      echo "data: The server time is: {$time}\n\n";

      flush(); 

  }   


下载 演示

  • 暂无任何回答