NowJS 是一个实现了 JavaScript 服务器端进行通讯的框架,基于 Node.js 开发。
示例代码:
服务器端:
<script src="/nowjs/now.js"></script>
var everyone = require("now").initialize(httpServer);
everyone.now.getServerInfo = function(callback){
db.doQuery(callback);
return "done!"
}
everyone.now.distributeMessage = function(message){
everyone.now.receiveMessage(this.now.name, message);
};
客户端代码:
<script type="text/javascript" src="http://localhost:8080/nowjs/now.js"></script>标签:function,everyone,服务器端,JavaScript,NowJS,通讯,message,now From: https://blog.51cto.com/u_2650279/6142847
<script type="text/javascript">
now.ready(function(){
// alerts "Hello World!"
alert(now.msg);
});
</script>