Welcome Guest, Not a member yet? Register   Sign In
Pusher not working with codeigniter
#1

[eluser]Unknown[/eluser]
I have a simple scenario. User submits a comment and an alert should be displayed that there is a new comment.

This is in my view file's header.


Code:
[removed]



var pusher = new Pusher('key');
var channel = pusher.subscribe('comments-2');



channel.bind('new_comment', function(data) {
    alert('An event was triggered with message: ' + data.message);


});

A comment submission is handled by the following method:

Code:
function comment() {




                    $i = $this->session->userdata('id') ;
                    $u = $this->session->userdata('user') ;
                    $ti = $this->chat_model->getTopicID($i);
                    $c = $this->input->post('title') ;


                    $arr = array(

                        'comment' => $c,
                        'topic_id' => $ti,
                        'comment_user' => $u                    

                    );


                    $this->db->insert('comments',$arr) ;

                    $this->pusher->trigger('comments-2', 'new_comment', array(

                        'comment' => $c,
                        'topic_id' => $ti,
                        'comment_user' => $u        

                    ));


                    $data['id'] = $i ;
                    $this->load->view('chat',$data);


        }

Using this library: https://github.com/antonigiske/Pusher-CI

Help please
#2

[eluser]sanir[/eluser]
hi,

Please elebrate which error you have seen.


Thanks,
Nasir Ranta




Theme © iAndrew 2016 - Forum software by © MyBB