admin管理员组

文章数量:1395436

I am using Pusher for real-time page update for my static JavaScript app. when i tried to invoke trigger event its not responding anythin. here is my code

var pusher = new Pusher('5f5ebdf0612fbafff349');  
var myChannel = pusher.subscribe('channel_1')  
myChannel.trigger("say_hello", {'name':"Jai", 'age':22});

I am using Pusher for real-time page update for my static JavaScript app. when i tried to invoke trigger event its not responding anythin. here is my code

var pusher = new Pusher('5f5ebdf0612fbafff349');  
var myChannel = pusher.subscribe('channel_1')  
myChannel.trigger("say_hello", {'name':"Jai", 'age':22});
Share Improve this question edited Jun 12, 2011 at 22:25 Soufiane Hassou 17.7k2 gold badges41 silver badges76 bronze badges asked Jun 12, 2011 at 22:23 Jai KeerthiJai Keerthi 5,6052 gold badges18 silver badges9 bronze badges 2
  • 5 You may want to remove your Pusher API key from the posted code, just FYI :) – Tak Commented Jun 12, 2011 at 22:35
  • Can you elaborate on error messages or debug output? Your code looks okay. Can you see the event in the Pusher web console? – Tak Commented Jun 12, 2011 at 23:36
Add a ment  | 

1 Answer 1

Reset to default 6

You can only trigger events Using JS ( It is not advisable until you clearly know what you are doing) once you have a subscription successfully registered with Pusher for Client Side Triggers.

It is important that you apply additional care when binding to client- prefixed events, since these originate from other users (client side), and could be subject to tampering by a malicious user of your site (any one can modify and execute your JS).

Read this for getting acces to client side event triggering: http://pusher./docs/client_api_guide/client_events#trigger-events

本文标签: jqueryTrigger Pusher event from javascriptStack Overflow