You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
vardata={ajax_data: 22};varblob=newBlob([JSON.stringify(data)],{type : 'application/json'});// Content-Type of the Beacon HTTP request will be application/json in this casenavigator.sendBeacon('ajax.php',blob);
sendBeacon 设置 contentType
如果是 post 请求,需要传 http header:
对应的 fetch 请求是可以这样的,但是 sendBeacon 好像不支持这种。
sendBeacon 有下面三种参数传递方式
这种情况下如果是跨域请求可能是报错跨域错误,详情可查看 sendBeacon cors error
参考文档
https://requestmetrics.com/building/using-the-beacon-api
https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon
https://usefulangle.com/post/63/javascript-navigator-sendbeacon-set-form-http-header
The text was updated successfully, but these errors were encountered: