Postingan lainnya
Cara menggunakan pusher?
gan mau tanya ane bikin pusher nah udh jalan tapi kenapa pas di klik send halamanny ngerefresh ya terus isi dari komenanny malah ilang tinggal inputanny doang dan harus di refresh lg kalo biar muncul dan itu jg berlaku buat orang yang buka jg?
ini viewny
public function replyMessage()
{
$data = array(
'post_id' => $this->input->post('post_id'),
'id_slug' => $this->input->post('id_slug'),
'user_id' => $this->input->post('user_id'),
'isi' => $this->input->post('isi')
);
$options = array(
'cluster' => 'ap1',
'useTLS' => true
);
$pusher = new Pusher\Pusher(
'cf9744ce6c78ad628245',
'92aedeb551c1cc4e44e5',
'989923',
$options
);
if ($this->db->insert('komen', $data)) {
$push = $this->db->get('komen')->result_array();
foreach ($push as $k) {
$data_pusher[] = $k;
}
$pusher->trigger('my-channel', 'my-event', $data_pusher);
}
}
}
ini controler
<section class="ftco-section bg-light">
<?php if ($postfes) : ?>
<div style=" box-shadow: 0 8px 10px 0 rgba(0, 0, 0, 0.5);" class="row justify-content-center mr-3 ml-3" data-aos="fade-up">
<img height="650px" src="<?= base_url('assets/img/posting/') . $postfes->image ?>" class="card-img-top">
<div class="card-body">
<h1 class="card-title text-center"><?= $postfes->namaFes ?></h1>
<div class="row justify-content-center">
<p><b>Daerah : </b><?= $postfes->nm_daerah ?></p>
<p class="ml-4"><b>Tempat : </b><?= $postfes->tempat ?></p>
</div>
<div class="row justify-content-center">
<p><b>Tanggal : </b><?= $postfes->tanggal ?></p>
<p class="ml-4"><b>Sampai : </b><?= $postfes->tanggal2 ?></p>
</div>
<p class="text-center"><b>Author : </b><a href="<?= base_url() ?>home/profile/<?= $postfes->id ?>"><?= $postfes->firstName ?></a></p>
<p style="font-size: 12px;" class="text-center font-italic"><b>Kategori : </b><?= $postfes->nama_kat ?></p>
<p><?= $postfes->deskripsi ?></p>
</div>
</div>
<?php endif; ?>
<div class="container">
<h3 class="text-center">Komentar</h3>
<div class="row">
<div class="col-md-6 m-auto">
<div id="pesan">
<?php foreach ($komen as $k) {
echo "<p>
<span><b> $k->firstName</b></span> -
<span> $k->isi</span>
</p>
";
}
?>
</div>
<?php if (!$this->session->userdata('email')) : ?>
<p class="text-center">Login untuk berkomentar</p>
<?php else : ?>
<div class="form-group">
<input type="hidden" name="post_id" id="post_id" class="form-control" value="<?= $postfes->id_post ?>">
<input type="hidden" name="id_slug" id="id_slug" class="form-control" value="<?= $postfes->url_slug ?>">
<input type="hidden" name="user_id" id="user_id" class="form-control" value="<?= $_SESSION['id']; ?>">
<textarea class="form-control" name="isi" id="isi" placeholder="masukan komen anda"></textarea>
</div>
<div class="form-group">
<input type="button" onclick="replyMessage()" value="send"></input>
</div>
<?php endif; ?>
</div>
</div>
</div>
</section>
0
1 Jawaban:
Coba di cek lagi dokumentasi menjalankan pusher dengan php, seharunya ada code yg jalan juga di view sebagai penerima dan dicontroller sebagai pengirim.
0