how to schedule ajax calls every N seconds?

前端 未结 4 1496
天命终不由人
天命终不由人 2020-12-02 02:17

If I want a whole page to reload every N seconds, I would put something like this in the HTML: meta http-equiv=\"refresh\" content=\"5\"

Is there a sta

4条回答
  •  醉话见心
    2020-12-02 02:31

    I assume that there is a servlet with URL Pattern /UpdateCount is configured in web.xml to provide dynamic data/content and there is a div element countStatDiv in the jsp page.

    The following code refreshes/updates the content of countStatDiv at every 30 seconds using GET method and variable seconds value can be changed according to the need:

                    
    

提交回复
热议问题