Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.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 为什么数据不显示在laravel的视图文件中?_Jquery_Laravel - Fatal编程技术网

Jquery 为什么数据不显示在laravel的视图文件中?

Jquery 为什么数据不显示在laravel的视图文件中?,jquery,laravel,Jquery,Laravel,我有一个刀片文件,代码如下 <div id="id1">0</div> <div id="id2">0</div> <div id="id3">0</div> 我可以在推送程序中触发事件,但不能在视图文件中触发 js $(document).ready(function(){ $.ajaxSetup({ headers: {

我有一个刀片文件,代码如下

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

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

 <div id="id3">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.id,
      method: 'get',
      dataType: 'json',
      success: function(data) {
         //parse the server side response
         console.log(data);
         ajax = null;
      }
    });

    //node.innerHTML = ajax.data;

  });
});
// Pusher
    var pusher = new Pusher('xxxxxxxxxxxxx', {
        cluster: 'ap3',
        encrypted: true
      });
   // Subscribe to the channel we specified in our Laravel Event
      var channel = pusher.subscribe('my-channel');
   // Binding a function to a Event
     channel.bind('App\Events\UpdatedTime', function(data){
     document.getElementById(data.UpdatedTime.target).innerHTML = data.UpdatedTime.value; //**It is not working**
    
事件文件

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

    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return \Illuminate\Broadcasting\Channel|array
     */
    public function broadcastOn()
    {
        return new Channel('my-channel');
    }
路由/web.php

Route::get('/getTime/{id}', 'App\Http\Controllers\TimeController@getTime');
为什么我在访问URL
后无法获取视图文件中的数据http://www.project.test/getTime/2< /代码>给出空白页。我需要带有特定ID的time()的div

我怎么能这样做? 有人能帮忙吗?
谢谢

它应该是
document.getElementById(“id”+数据.updateTime.target)…。
@Cuong Le Ngoc在传递document.getElementById(“id”+数据.updateTime.target)后,它不工作了。Sry。你是说你的pusher部分不工作还是ajax部分?pusher部分工作了,我可以在pusher中获取特定ID的ID和时间()。问题是,如果键入//我无法在视图中获取Id:2的时间()。它显示一个空白页。我怎样才能做到这一点?看看拉威尔的日志,看看有什么问题。该url不应该是
project.test/getTime/id2
id2
是div的
id
属性
Route::get('/getTime/{id}', 'App\Http\Controllers\TimeController@getTime');