What's the best way for the client app to immediately react to an update in the database?

前端 未结 4 484
Happy的楠姐
Happy的楠姐 2021-02-05 23:24

What is the best way to program an immediate reaction to an update to data in a database?

The simplest method I could think of offhand is a thread that checks the databa

4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-06 00:21

    Unfortunately there's no way to push data to a web browser - you can only ever send data as a response to a request - that's just the way HTTP works.

    AJAX is what you want to use though: calling a web service once a second isn't excessive, provided you design the web service to ensure it receives a small amount of data, sends a small amount back, and can run very quickly to generate that response.

提交回复
热议问题