Periodic refresh or polling

I am trying to use periodic refresh(ajax)/polling on my site by XMLHttp(XHR) to check if a user has a new message on the database every 10 seconds, then if there is inform him/her by creating a div dynamically like this: function shownotice() { var divnotice = document.createElement("div"); var closelink = document.createElement("a"); closelink.onclick = this.close; closelink.href = "#"; closelink.className = "close"; closelink.appendChild(document.createTextNode("close")); divnotice.appendChild(closelink); divnotice.className = "notifier"; divnotice.setAttribute("align", "center"); document.body.appendChild(divnotice); divnotice.style.top = document.body.scrollTop + "px"; divnotice.style.left = document.body.scrollLeft + "px"; divnotice.style.display = "block"; request(divnotice); } Is this a reliable or stable way to check message specifically since when I look under firebug, a lot of request is going on to my database? Can this method make my database down because of too much request? Is there another way to do this since when I login to facebook and check under firebug, no request is happening or going on but I know they are using periodic refresh too... how do they do that?

以上就是Periodic refresh or polling的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏