【问题标题】:Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's exp主线程上的同步 XMLHttpRequest 已被弃用,因为它对最终用户的 exp 产生不利影响
【发布时间】:2017-05-08 08:25:29
【问题描述】:

我遇到了一个非常烦人的问题。我添加了以下 jQuery 脚本,以便能够将 swipeleftswiperight 用于菜单:

<link rel="stylesheet" href="//code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<script src="//code.jquery.com/jquery-2.1.4.min.js"></script>
    <script src="//code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script> 

现在,每当我单击菜单中的 url 链接时,当我到达目标页面时,页面的样式完全不符合格式,并且控制台中会显示以下警告。

jquery-2.1.4.min.js:4 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/.

这是来自jquery-2.1.4.min.js:4的代码:

f(f.open(a.type,a.url,a.async,a.username,a.password),a.xhrFields)for(e

我点击一个 url 的地方会出现什么问题并出现此问题?在我添加上面的 jQuery 脚本之前,这不是问题。此外,如果我通过在浏览器中重新加载出现警告的页面来重新加载该页面,则该页面的格式会恢复到应有的状态。

有什么想法吗?

如果有人想看这个直播,请在下面评论,我会放链接。

【问题讨论】:

  • 我没有你的问题的答案,但我建议使用未缩小的 JQuery 库进行开发,它们往往更容易调试。
  • @George 他们到底是什么?我通常使用&lt;script src="http://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"&gt;&lt;/script&gt;,但仅此一项,甚至仅此一项,jquery.mobile 将不允许swipeleft 工作。
  • 只需删除 .min
  • @George 这有助于格式化,但现在我收到这个错误,加载了Failed to find a valid digest in the 'integrity' attribute for resource 'http://code.jquery.com/jquery-3.1.1.js' with computed SHA-256 integrity '16cdPddA6VdVInumRGo6IbivbERE8p7CQR3HzTBuELA='. The resource has been blocked.
  • 我也认为滑动不再有效。

标签: javascript jquery url asynchronous swipe


【解决方案1】:

在 jQuery 和 jquery.mobile 库之间使用如下:

<script type="text/javascript">
$(document).bind("mobileinit", function () {
    $.mobile.ajaxEnabled = false;
});
</script>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-16
    • 1970-01-01
    • 1970-01-01
    • 2015-09-16
    • 2015-12-20
    • 1970-01-01
    相关资源
    最近更新 更多