最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

jquery - Trigger Pusher event from javascript - Stack Overflow

programmeradmin9浏览0评论

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

发布评论

评论列表(0)

  1. 暂无评论