Trigger Pusher event from javascript
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('channe开发者_StackOverflowl_1')
myChannel.trigger("say_hello", {'name':"Jai", 'age':22});
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.com/docs/client_api_guide/client_events#trigger-events
精彩评论