HTTP
In some cases I need to send a request with some data for logging when the user does something like navigating to a different page or submitting a form. Consider this contrived example of sending some information to an external service when a link is clicked:
< a href = " /some-other-page " id = " link " > Go to Page </ a > < script > document . getElementById ( 'link' ) . addEventListener ( 'click' , ( e ) => {
…
The post Reliably sending HTTP requests when a user leaves a page first appeared on Lenix Blog .
This article is reprinted from https://blog.p2hp.com/archives/8732
This site is for inclusion only, and the copyright belongs to the original author.