【发布时间】:2017-10-12 04:24:15
【问题描述】:
我有一个使用 NodeJS 自动从 MySQL 显示信息的页面。如何使文本用户名或描述显示为引导警报,例如“alert alert-info”?
<time></time>
<div id="container">Loading ...</div>
<script src="socket.io/socket.io.js"></script>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script>
// create a new websocket
var socket = io.connect('http://localhost:8000');
// on message received we print all the data inside the #container div
socket.on('notification', function (data) {
var usersList = "<dl>";
$.each(data.users,function(index,user){
usersList += "<dt>" + user.user_name + "</dt>\n" +
"<dd>" + user.user_description + "\n" + "</dd>";
});
usersList += "</dl>";
$('#container').html(usersList);
$('time').html('Last Update:' + data.time);
});
</script>
【问题讨论】:
标签: javascript jquery node.js twitter-bootstrap