I'm currently learning pusher and applying it in my queuing management project. I almost done applying it in my project as I do this:
In my blade view file in section
var channel = pusher.subscribe('my-channel');
channel.bind('my-event', function(data) {
alert(JSON.stringify(data));
});
which I test that my pusher is working. Now my question is how do I refresh a specific div after the data was sent. Like this
var channel = pusher.subscribe('my-channel');
channel.bind('my-event', function(data) {
//refresh specific div here after the data was sent
});
I will show also the controller
public function store(Request $request)
{
$call = Call::create([
'letter' => $letter->letter,
'number' => $number->start,
'called' => 'NO',
'trans_id' => $request->input('trans_id'),
'guest_name' => $request->input('name'),
'amount' => $request->input('amount'),
'num_calls' => 0
]);
// pusher
$options = array(
'cluster' => 'ap1',
'useTLS' => true
);
$pusher = new Pusher(
env('PUSHER_APP_KEY'),
env('PUSHER_APP_SECRET'),
env('PUSHER_APP_ID'),
$options
);
$data = ['letter' => $call->letter, 'number' => $call->number, 'id' => $call->id];
$pusher->trigger('my-channel', 'my-event', $data);