Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.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
Jquery 传递给Symfony\Component\HttpFoundation\Response::setContent()的TypeError参数1的类型必须为string或null,对象为给定的,_Jquery_Laravel_Pusher - Fatal编程技术网

Jquery 传递给Symfony\Component\HttpFoundation\Response::setContent()的TypeError参数1的类型必须为string或null,对象为给定的,

Jquery 传递给Symfony\Component\HttpFoundation\Response::setContent()的TypeError参数1的类型必须为string或null,对象为给定的,,jquery,laravel,pusher,Jquery,Laravel,Pusher,我使用下面的代码,我需要从服务器获取time(),我在laravel中使用了推送器和队列 我使用的html(刀片文件)带有3个div,如下所示 <div id="divId1">0</div> <div id="divId2">0</div> <div id="divId3">

我使用下面的代码,我需要从服务器获取
time()
,我在laravel中使用了推送器和队列

我使用的html(刀片文件)带有3个div,如下所示


                <div id="divId1">0</div>

                <div id="divId2">0</div>

                <div id="divId3">0</div>

在js文件中

$(document).ready(function(){
 $.ajaxSetup({
     headers: {
          'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
    });

  document.querySelectorAll('*').forEach(function(node) {
    var data = '';
    ajax = $.ajax({
      url: '/getTime/' . node,
      method: 'get',
      success: function(data) {
         //parse the server side response
         console.log(data);
      }
    });
   });
});

 var pusher = new Pusher('xxxxxxxxxxxxxxx', {
        cluster: 'eu',
        encrypted: true
      })
      var channel = pusher.subscribe('time-updated');
   // Binding a function to a Event
     channel.bind('App\Events\TimeUpdated', function(data){
     console.log(data);
 });
class TimeUpdated implements ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

     public $timechanged, $divID;
    public function __construct($divID, $timechanged)
    {
       $this->timechanged = $timechanged;
       $this->divID = $divID;
    }

   
    public function broadcastOn()
    {
        return new Channel('time-updated');
    }
    
}

事件文件

$(document).ready(function(){
 $.ajaxSetup({
     headers: {
          'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
    });

  document.querySelectorAll('*').forEach(function(node) {
    var data = '';
    ajax = $.ajax({
      url: '/getTime/' . node,
      method: 'get',
      success: function(data) {
         //parse the server side response
         console.log(data);
      }
    });
   });
});

 var pusher = new Pusher('xxxxxxxxxxxxxxx', {
        cluster: 'eu',
        encrypted: true
      })
      var channel = pusher.subscribe('time-updated');
   // Binding a function to a Event
     channel.bind('App\Events\TimeUpdated', function(data){
     console.log(data);
 });
class TimeUpdated implements ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

     public $timechanged, $divID;
    public function __construct($divID, $timechanged)
    {
       $this->timechanged = $timechanged;
       $this->divID = $divID;
    }

   
    public function broadcastOn()
    {
        return new Channel('time-updated');
    }
    
}

Routes.php

Route::get('/getTime/{id}', 'App\Http\Controllers\TimeController@getTime');
  • 队列时间更改
  • 当我运行
    php artisan队列:work

    [2021-05-10 06:22:51][1] Processing: App\Jobs\TimeChange
    [2021-05-10 06:22:51][1] Failed:     App\Jobs\TimeChange
    [2021-05-10 06:22:51][2] Processing: App\Jobs\TimeChange
    [2021-05-10 06:22:51][2] Failed:     App\Jobs\TimeChange
    [2021-05-10 06:26:13][3] Processing: App\Jobs\TimeChange
    [2021-05-10 06:26:13][3] Failed:     App\Jobs\TimeChange
    
    有人能帮忙吗

    [2021-05-10 06:22:51][1] Processing: App\Jobs\TimeChange
    [2021-05-10 06:22:51][1] Failed:     App\Jobs\TimeChange
    [2021-05-10 06:22:51][2] Processing: App\Jobs\TimeChange
    [2021-05-10 06:22:51][2] Failed:     App\Jobs\TimeChange
    [2021-05-10 06:26:13][3] Processing: App\Jobs\TimeChange
    [2021-05-10 06:26:13][3] Failed:     App\Jobs\TimeChange