Save audio position via navigator.sendBeacon — the only reliable
way to flush a request during pagehide. fetch() is cancelled by
Safari/Chrome mobile when the document is being unloaded; beacon
keeps queued requests alive past tab close.
Beacons can't set arbitrary headers (no X-CSRF-TOKEN), so the CSRF
token rides as a form field instead — CsrfMiddleware accepts both.
Parameters
text_id: number
pos: number
Returns boolean
true if the user agent accepted the beacon for delivery
Save audio position via navigator.sendBeacon — the only reliable way to flush a request during pagehide. fetch() is cancelled by Safari/Chrome mobile when the document is being unloaded; beacon keeps queued requests alive past tab close.
Beacons can't set arbitrary headers (no X-CSRF-TOKEN), so the CSRF token rides as a form field instead — CsrfMiddleware accepts both.