Pusher Test
Test using the hosted Pusher API for realtime communication
by AaronLayton
HTML
<script src="http://js.pusher.com/1.10/pusher.min.js"></script>
<div id="results"></div>
JavaScript
var pusher = new Pusher('51014b4594200b72f769'); // Replace with your app key
// Enable pusher logging - don't include this in production
Pusher.log = function(message) {
if (window.console && window.console.log) window.console.log(message);
};
var channel = pusher.subscribe('test_channel');
channel.bind('data-changed', function(data){
updateResults(data)
});
function updateResults(data){
var resultElm= jQuery("#results");
var html = "";
for (var i=0; i < data.length; i++) {
html += "Title: " + data[i].title + " - " +
"Message: " + data[i].message;
}
resultElm.append(html);
}