Can the unload Event be Used to Reliably fire ajax Request?

前端 未结 5 905
萌比男神i
萌比男神i 2020-11-27 04:44

I need a method to monitor user edit sessions, and one of the solutions I\'m reviewing will have me using an unload event to send an ajax request to inform the

5条回答
  •  -上瘾入骨i
    2020-11-27 05:12

    Have you tried to use

    var i = new Image(1,1); 
    i.src='http://...'
    

    And just returning some empty image from server. I think it should be reliable, script will block. BTW: nice to add timestamp to prevent caching.

提交回复
热议问题