javascript - navigator.sendBeacon 在 Internet Explorer 浏览器中不起作用
问题描述
我在代理代码中编写了表单卸载事件在 Internet Explorer 浏览器中不起作用。
例子:
$(window).unload(function () {
$.ajax({ type: 'POST', url: 'WebAPI/api/Values/Get?id=1', contentType: "application/json; charset=utf-8 ", dataType: 'json', async: true, //阻止窗口关闭成功: function () { alert('sucess'); }, error: function () { alert('error'); } });
} );
解决方案
Internet Explorer is an obsolete browser. It doesn't have a lot of modern web features, including the beacon API (caniuse). You could feature-detect the beacon API and fall back to XMLHttpRequest
.
推荐阅读
- javascript - Data 给了我 {url: ......} 但 Data.url 在 nodejs 中给了我 undefined
- google-apps-script - Google Apps 脚本:切换案例始终默认结果
- python - 如何在 Django 中迁移多个数据库?
- c# - 从 http 站点下载文件失败并出现错误“System.IO.IOException”
- c# - 当列具有空值时,如何在 Gridview 中删除一行?
- angular - 如何在Angular Reactive Forms的另一个输入中获取选择选项文本
- kotlin - 如果构造函数不能返回 null,为什么我需要在初始化后进行类型检查?
- angular - Ng-template 标签不接受 *ngIf 指令
- deployment - 在 Azure Devops 中使用 Munits 部署项目时出现问题
- r - 子集 a 并按数据框分组,在 r 中具有多个条件和多个标准