Advertisement
Guest User

Untitled

a guest
Jul 30th, 2015
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. <script>
  2.  
  3. // create a new websocket
  4. var socket = io.connect('http://localhost:8000');
  5. // on message received we print all the data inside the #container div
  6. socket.on('notification', function (data) {
  7. var usersList = "<dl>";
  8. $.each(data.users,function(index,user){
  9. usersList += "<dt>" + user.user_name + "</dt>n" +
  10. "<dd>" + user.user_description + "n" +
  11. "<figure> <img class='img-polaroid' width='50px' src='" + user.user_img + "' /></figure>"
  12. "</dd>";
  13. });
  14. usersList += "</dl>";
  15. $('#container').html(usersList);
  16.  
  17. $('time').html('Last Update:' + data.time);
  18. });
  19.  
  20. ws://localhost:8000/notification
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement