jQuery ajax async: false 导致一个奇怪的警告? [英] jQuery ajax async: false causes a strange warning?
问题描述
在我的 JS 应用程序中,我有许多带有 async: false
的 Ajax 调用.我正在使用最新的 Chrome 浏览器,最近在我的控制台中出现以下警告.
In my JS App, i have many Ajax calls with async: false
. I am using latest Chrome browser and in my console below warning appears recently.
主线程上的同步 XMLHttpRequest 被弃用,因为其对最终用户体验的不利影响.如需更多帮助,检查 http://xhr.spec.whatwg.org/.
Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/.
现在我正在尝试将所有 async: false
更改为 async: true
.但它会导致很多错误,因为我的应用程序需要使用 async: false
运行.
Now i am trying to change all async: false
to async: true
. But it causes a lot of error because my app needs to run with async: false
.
警告只是一个错误还是什么?我可以担心还是忽略它?
Is the warning just a bug or something? Can i worry about that or ignore that?
推荐答案
警告只是一个错误还是什么?
Is the warning just a bug or something?
不,这不是错误.出于消息中所述的原因,同步请求确实已被弃用.
No, it's not a bug. Sync requests are indeed deprecated, for the reasons stated in the message.
我可以担心还是忽略它?
Can i worry about that or ignore that?
您应该听取建议并对您的应用进行适当的更改(是的,这并不像将 async: false
更改为 async: true
那样简单).
You should heed the advice and make the appropriate changes to your app (and yes, it's not as simple as just changing async: false
to async: true
).
也许这有助于更好地理解异步操作:
Maybe this helps to understand asynchronous operations better:
这篇关于jQuery ajax async: false 导致一个奇怪的警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!