ajax方法执行同步的黄色警告:Synchronous XMLHttpRequest on the main thread is deprecated的解决方案

简介: ajax方法执行同步的黄色警告:Synchronous XMLHttpRequest on the main thread is deprecated的解决方案


[Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.


翻译:在主线程同步XMLHttpRequest是不赞成的,因为对最终用户的体验有不利影响。更多帮助,检查HTTP:/ / XHR。spec.whatwg。org /


以上警告信息在ajax方法执行同步操作(等有了返回值才执行下面的js,会短暂阻断程序继续执行)的时候出现,即:async:false。同步执行AJAX不影响程序的正常执行。当然,如果业务层面允许,推荐异步执行AJAX,即将async属性设置为true。(当然,ajax()方法async缺省下为true)


Done!


相关文章
|
JavaScript 前端开发 容器
AJAX载入外部JS文件到页面并让其执行的方法(附源码)
AJAX载入外部JS文件到页面并让其执行的方法(附源码)
113 0
|
7月前
|
前端开发 JavaScript
jQuery - AJAX load() 方法
jQuery load() 方法是简单但强大的 AJAX 方法。
126 6
|
8月前
|
JSON 前端开发 JavaScript
jQuery AJAX 方法
jQuery AJAX 方法
75 1
|
8月前
|
JavaScript 前端开发
jQuery - AJAX load() 方法
jQuery - AJAX load() 方法
37 2
|
8月前
|
XML JavaScript 前端开发
jQuery - AJAX get() 和 post() 方法
jQuery - AJAX get() 和 post() 方法
47 6
|
8月前
|
缓存 JavaScript 前端开发
jQuery - AJAX get() 和 post() 方法
jQuery - AJAX get() 和 post() 方法
52 4
|
8月前
|
JSON 前端开发 JavaScript
jQuery AJAX 方法
jQuery AJAX 方法
54 1
|
8月前
|
JavaScript 前端开发
jQuery - AJAX load() 方法
jQuery - AJAX load() 方法
36 1
|
8月前
|
缓存 JavaScript 前端开发
jQuery - AJAX get() 和 post() 方法
jQuery - AJAX get() 和 post() 方法
54 0
|
10月前
|
前端开发 JavaScript API
js【详解】ajax (含XMLHttpRequest、 同源策略、跨域、JSONP)
js【详解】ajax (含XMLHttpRequest、 同源策略、跨域、JSONP)
102 0