dsogx84602 2011-11-01 19:47
浏览 69

使用ajax每秒访问数据库

I have a JavaScript script, that uses Ajax to call PHP page, the php page fetch the new updates from MYSQL database..

Ajax request is repeated every one second .

Does it a good practice to access database every second ? Is there any other suggestion to improve this operation ?

edit

I want to make something like twitter real-time updates, each second I will retrieve only the new data, if there is no new data, nothing will return from database ( but still access the database every 1 sec)

  • 写回答

4条回答 默认 最新

  • dtiu94034 2011-11-01 19:51
    关注

    Make sure that you are not using setInterval but are using callbacks when your ajax call is successful or else you might have a backlog of calls that get stuck.

    Also you might want to utilize some long-polling methods like websockets, comet, or server-sent-events.

    评论

报告相同问题?

悬赏问题

  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏