- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我正在编写一个使用 Comet/Long Polling 来保持网页最新的 AJAX 网络应用程序,我注意到在 Chrome 中,它将页面视为一直在加载(选项卡的图标一直在旋转)。
我认为这对于 Google Chrome + Ajax 来说是正常的,因为即使是 Google Wave 也有这种行为。
今天我注意到 Google Wave 不再使加载图标保持旋转,有人知道他们是如何解决这个问题的吗?
这是我的ajax调用代码
var xmlHttpReq = false;
// Mozilla/Safari
if (window.XMLHttpRequest) {
xmlHttpReq = new XMLHttpRequest();
}
// IE
else if (window.ActiveXObject) {
xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHttpReq.open('GET', myURL, true);
xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlHttpReq.onreadystatechange = function() {
if (xmlHttpReq.readyState == 4) {
updatePage(xmlHttpReq.responseText);
}
}
xmlHttpReq.send(null);
最佳答案
我厚着脸皮偷走了Oleg的测试用例,稍微调整了一下模拟长轮询。
load.html
:
<!DOCTYPE html>
<head>
<title>Demonstration of the jQery.load problem</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
jQuery(document).ready(function() {
$('#main').load("test.php");
});
</script>
</head>
<body>
<div id='main'></div>
</body>
</html>
test.php
:
<?php
sleep(5);
?>
<b>OK!</b>
结果很有趣:在 Firefox 和 Opera 中,在 XMLHTTPRequests 期间没有显示加载指示器。 Chrome 让它旋转......我怀疑 Google Wave 不再使用长轮询(但是,例如,每 X 秒轮询一次,以节省资源),但我无法测试它,因为我没有帐户.
编辑: 我想通了:在加载 test.php
时添加一点延迟(可以尽可能小)之后,加载指示器在 load.html
已加载:
jQuery(document).ready(function() {
setTimeout(function () {
$('#main').load("test.php");
}, 0);
});
不知何故,原样confirmed in a comment在另一个答案中,当浏览器重新获得控制权以完成页面呈现时,指示器停止旋转。另一个优点是不能通过按 Esc 来中止请求。
关于javascript - Chrome 的加载指示器在 XMLHttpRequest 期间不断旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2703861/
我只需要以下代码的清晰解释来创建 XMLHttpRequest . var xhr = false; if (window.XMLHttpRequest) { xhr = new XMLHtt
我无法让 XMLHttpRequest 对象在我正在编写的仪表板小部件中正常工作。我将其隔离为一个在 main.js 文件的全局范围内不起作用的简单示例: xhr = new XMLHttpR
首先,如果我要说的没有任何意义,请允许我道歉。我已经离开了我的舒适区,我真的不知道我在做什么。照这样说... 我正在使用 Google Drive File Picker library允许用户从他们
我还有一个问题。 XMLhttpRequests 困扰着我。一切现在都在数据库中,但我需要这些数据来更新我的页面以加载或重新加载第一页。 XHR 在触发 PHP 脚本的 JavaScript 文件中触
我试图了解从 WebAssembly 调用 XmlHttpRequest 的最佳和最有效的方法是什么。 我找到了 http://webassembly.org/getting-started/js-a
我有兴趣只提取 XHR 的网址,而不是网页中的每个网址: 这就是我提取页面中每个 url 的代码: import scrapy import json from scrapy.selector imp
有没有办法检测 XmlHttpRequest 无法解析 URL?使用错误的 URL 调用 Open(...) 时似乎不会抛出异常。 最佳答案 HTTP 状态代码将为零。 这适用于无法建立连接且未使用代
有没有办法检测 XmlHttpRequest 无法解析 URL?使用错误的 URL 调用 Open(...) 时似乎不会抛出异常。 最佳答案 HTTP 状态代码将为零。 这适用于无法建立连接且未使用代
当我在 mozilla 浏览器中运行该应用程序时,出现以下错误 主线程上的同步 XMLHttpRequest 已被弃用,因为它会对最终用户的体验产生不利影响。更多帮助 http://xhr.spec.
我正在使用 javascript 通过 XMLHttpRequest 在 div 中加载数据,现在我想知道是否有可能在加载的 div 中创建另一个 XMLHttpRequest,这样一个新的 oncl
这个问题在这里已经有了答案: Are 'Arrow Functions' and 'Functions' equivalent / interchangeable? (4 个答案) 关闭 3 年前。
我感觉到很多关于使用新的 HTML5 JS XHR 技术的简单跨域 XmlHttpRequest 方法的讨论。给定下面的标准 JavaScript XHR 代码... var xhr=new XM
我是 PWA 的初学者,我尝试让我的代码调用 API,然后将其存储在浏览器的缓存中。但是我看到 axios 使用 XMLHttpRequest 而不是 fetch API,所以我无法缓存我的 API
这个问题在这里已经有了答案: Can we omit parentheses when creating an object using the "new" operator? (6 个答案) 关闭
这段代码块有什么区别: var xhr = new XMLHttpRequest(); xhr.upload.addEventListener("progress", uploadProgress,
我有一个 ajax 调用,我在其中使用 jQuery.ajax() 向 mvc 操作发出请求。这一切都很好。但是,由于某些表单具有文件控件,我将其从使用 jQuery.ajax() 更改为使用 XML
我对 Node.js 和 XMLHttpRequest 非常陌生,所以如果这是一个简单答案的问题,请耐心等待。 我目前正在尝试抓取一个 friend 的网页(当然要经过他的许可),其中包含视频和字幕。
我在 Microsoft Edge 中收到此错误。这是什么意思?在线搜索主要是为我提供有关人们在产品中遇到错误的线索。 最佳答案 如果 XMLHttpRequest 调用 ( www.mysite.s
我正在使用 jQuery 和 Office JS API 构建一个 Outlook 加载项。我在开发时有一个本地服务器正在运行,我正在尝试向我站点的主服务器上的端点提交一个 POST 请求。每次尝试提
当使用 FormData 对象将文件附加到请求时,我一直试图找到一种方法来在 XMLHttpRequest 对象上设置我自己的边界。我看过很多关于这个的帖子,每个人都说“不要设置边界,它会自动为你生成
我是一名优秀的程序员,十分优秀!