将消息轮询显示(jquery)。
<script type="text/javascript"> var _page = 1; $(function(){ show(); function show(){ $.getJSON("/message/getMessage?page="+_page,function(data){ var _arr = new Array(); for ( var i = data.messages.length;i>0; i-- ) { _arr.push(data.messages[i-1].content); if(data.messages[i-1].lastPage==1){ _page = 0; } } if(_arr.length>0){$(".message").text(_arr.pop())}; var _time = setInterval(function(){ if(_arr.length>0){ $(".message").text(_arr.pop()); }else{ clearInterval(_time); show(); } },6000); _page = _page + 1; }); } }); </script>
相关推荐
breakpoints 2020-05-17
yanyongtao 2020-11-02
shawsun 2020-07-04
us0 2020-06-28
cxcxrs 2020-06-26
小海 2020-06-25
Skyline 2020-06-16
jiedinghui 2020-06-04
数据与算法之美 2020-05-27
cuterabbitbaby 2020-05-14
吴小伟 2020-05-09
程序员之怒 2020-04-26
doupoo 2020-05-04
Ghero 2020-05-03
chibangyuxun 2020-04-30
ThinkingLink 2020-04-26