AJAX and user leaving a page

前端 未结 4 1665
心在旅途
心在旅途 2021-02-04 05:48

I\'m working on a chat and I\'m trying to figure out how I can detect that the user has left the page or not. Almost everything is being handled by the database to avoid the fro

4条回答
  •  故里飘歌
    2021-02-04 06:38

    This is related to the answer above. https://stackoverflow.com/a/10272651/1306144

    This will execute the ajax call every 1 sec. (1000)

    function callEveryOneSec() {
        $jx.ajax({}); // your ajax call
    }
    
    setInterval(callEveryOneSec, 1000);
    

提交回复
热议问题