首页 > 解决方案 > 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'); } });
} );

标签: javascriptasp.net

解决方案


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.


推荐阅读