Skip to content

Commit

Permalink
feat: navigator.sendBeacon
Browse files Browse the repository at this point in the history
  • Loading branch information
sunven committed Apr 12, 2024
1 parent 0fefc2f commit 5c3d55f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion docs/notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@

:tada: navigator.sendBeacon

- 允许开发者在用户离开一个页面时异步地向服务器发送小量数据
- 通过post方式发送,network 类型显示为ping
- 少量,异步
- 当用户关闭页面时,常规的 AJAX 请求可能会被浏览器中止,导致数据无法发送成功。但 sendBeacon() 可以确保数据在页面关闭后依然被发送,不会阻塞页面的关闭
- 可以跨域发送数据,无需担心跨域问题。

:::

Expand Down

0 comments on commit 5c3d55f

Please sign in to comment.