和其他许多人一样,我的网站也在使用jQuery.当我打开开发人员工具时,我看到一条警告,说明XMLHttpRequest是

deprecated because of its detrimental effects to the end user's experience.

I went on and read part of the documentation, but it was fairly technical. Can someone explain the consequences of shifting from XMLHTTPRequest to WHATWG in simple terms? It says it happened in 2012.

此外,文档还指出,workers外部的同步XMLHttpRequest正在从web平台上删除,当这种情况发生时,如果用户代理将它们包含在服务中,它们是否需要修改现有代码?

推荐答案

To avoid this warning, do not use:

async: false

in any of your $.ajax() calls. This is the only feature of XMLHttpRequest that's deprecated.

默认值为async: true,因此如果您从未使用过此选项,那么如果真的删除了该功能,代码应该是安全的.

However, it probably won't be -- it may be removed from the standards, but I'll bet browsers will continue to support it for many years. So if you really need synchronous AJAX for some reason, you can use async: false and just ignore the warnings. But there are good reasons why synchronous AJAX is considered poor style, so you should probably try to find a way to avoid it. And the people who wrote Flash applications probably never thought it would go away, either, but it's in the process of being phased out now.

Notice that the Fetch API that's replacing XMLHttpRequest does not even offer a synchronous option.

Jquery相关问答推荐

无法通过单击从元素获取数据

使用 shell 脚本判断 json 数组响应是否具有特定用户名和状态的 jq 命令

如何限制select2中的字符?

ASP.NET MVC - Ajax 将空值传递给控制器

将 HTML5 Canvas 转换为要上传的文件?

是否可以使用 javascript 打开一个弹出窗口,然后检测用户何时关闭它?

从 JQuery.ajax 成功数据中解析 JSON

延迟后运行功能

试图检测浏览器关闭事件

jQuery计算所有文本字段中的值的总和

将 CSS 应用于 jQuery 对话框按钮

您如何处理 jQuery 中的表单更改?

移动 chrome 在滚动时触发调整大小事件

如何签入用户已在 Google recaptcha 中选中复选框的 js?

禁用 jquery Select 的下拉菜单

如何通过jQuery函数仅获取直接子元素

jQuery - 从元素内部 Select 元素

将多个参数传递给 jQuery ajax 调用

是否可以将 async:false 设置为 $.getJSON 调用

使用 Chosen 插件更改 Select 中的 Select