Jquery 为什么未在浏览器的视图(刀片)文件中更新触发的推送器数据?
我有带3个div的刀片文件 欢迎使用.blade.phpJquery 为什么未在浏览器的视图(刀片)文件中更新触发的推送器数据?,jquery,laravel-5,Jquery,Laravel 5,我有带3个div的刀片文件 欢迎使用.blade.php <div id="id1">0</div> <div id="id2">0</div> <div id="id3">0</div> <script> //pusher var pusher = new Pusher('xxxxxxxxxxxx', { clu
<div id="id1">0</div>
<div id="id2">0</div>
<div id="id3">0</div>
<script>
//pusher
var pusher = new Pusher('xxxxxxxxxxxx', {
cluster: 'eu',
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){
target = data.id;
console.log(data);
value = data.value;
var div1 = document.getElementById(target);
div1.innerHTML =value;
});
</script>
Route::get('/getTime/{id}', 'App\Http\Controllers\TimeController@getTime');
事件文件
public $id, $value;
public function __construct($id, $value)
{
$this->id = $id;
$this->value = $value;
}
public function broadcastOn()
{
return new Channel('my-channel');
}
路由/web.php
<div id="id1">0</div>
<div id="id2">0</div>
<div id="id3">0</div>
<script>
//pusher
var pusher = new Pusher('xxxxxxxxxxxx', {
cluster: 'eu',
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){
target = data.id;
console.log(data);
value = data.value;
var div1 = document.getElementById(target);
div1.innerHTML =value;
});
</script>
Route::get('/getTime/{id}', 'App\Http\Controllers\TimeController@getTime');
在浏览器中传递URL后,
我只能看见
0
0
0
在浏览器中,
实际上,它应该在浏览器中
0
1511
0
如何在浏览器中获取触发的事件值?
有人能帮忙吗
谢谢