Advertisement
nubilfi

display data from socket

Jan 12th, 2017
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script src="/socket.io/socket.io.js" type="text/javascript"></script>
  2. <script>
  3.     var socket = io();
  4.         socket.on('items', function (data) {
  5.             console.log(data);
  6.             var html='';
  7.             for (var i = 0; i < data.length; i++) {
  8.                 html=html+'<li class="list-group-item" id="listGroup">'+data[i].item_name+'<span class="badge">'+data[i].stock+'</span></li>';
  9.             }
  10.             $('#listItem').html(html);
  11.         });
  12. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement