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);
在 iOS 13 的手机上 发现在端内打开 webview 发生了崩溃,报错信息: iOS 13 不支持 POST body 里面包含 Blob 或者 File 类型的数据。改成使用 fetch 请求后,上述问题不再复现。
The text was updated successfully, but these errors were encountered:
fetch和sendBeacon最大的区别
需要注意的问题
一、跨域请求
使用 sendBeacon 发跨域请求时,需要注意以下两点
二、接口参数为 json类型时
sendBeacon Data 支持的参数类型如图
Fetch post 请求,需要传 http header:
sendBeacon:使用Blob类型来实现。把Blob内容的格式类型设置为json格式
The text was updated successfully, but these errors were encountered: