navigator.sendBeacon('https://px.effirst.com/api/v1/ping', JSON.stringify({
timestamp: Date.now(),
page: location.href,
}))
异步、不会阻塞页面关闭;
专为 “上报数据” 设计;
在 Network 中你能看到 ping 请求;
请求类型是 beacon,不是 fetch 或 xhr。
navigator.sendBeacon('https://px.effirst.com/api/v1/ping', JSON.stringify({
timestamp: Date.now(),
page: location.href,
}))
异步、不会阻塞页面关闭;
专为 “上报数据” 设计;
在 Network 中你能看到 ping 请求;
请求类型是 beacon,不是 fetch 或 xhr。