经常使用jquery加载页面有什么不良影响吗?
<script type="text/javascript">
$(function(){
setInterval(function(){
$('#profil_resmi').load('profile.php?randval=' + Math.random());
},1000);
});
</script>
我的代码在上面。在我的页面中使用此代码对浏览器或当前页面有什么压倒性的影响吗?
<script type="text/javascript">
$(function(){
setInterval(function(){
$('#profil_resmi').load('profile.php?randval=' + Math.random());
},1000);
});
</script>
my code is above.is there any overwhelming effect over browser or over current page of using this code in my page ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
你将锤击你的服务器;
如果请求花费的时间超过 1 秒才能成功(这并非不现实),那么随着时间的推移,您将拥有越来越多的并发连接。
在开始新的请求之前,您应该确保之前的请求已完成(无论是成功还是失败)。
You will hammer your server;
If requests take longer than 1s to succeed (which is not unrealistic), then you will have more and more simultaneous connections as time goes on.
You should ensure that previous requests have finished (either by success or failure) before starting a new one.
这是很多要求。仅当您知道需要它时才使用它。 当您的服务器过载/在线用户较多时,可能会出现一些问题
That's a lot of requests. Use it really only in case when you know that you'll need it. It could make some problems when your server is overloaded/there are many users online
如果有许多用户打开此页面,则 Web 服务器可能会受到大量 HTTP 请求的攻击。因此,请确保该服务器能够在有意义的时间内响应所有这些请求。如果遇到问题,您可以增加这些请求之间的时间。
If you have many users opening this page the web server could potentially be hammered with lots of HTTP requests. So make sure that this server is capable of responding to all of them in a meaningful time. You could increase the time between those requests if you encounter problems.
您可能需要注意某些浏览器中的内存泄漏,尤其是较旧的浏览器。大量 DOM 操作是一些旧浏览器存在漏洞的地方。我不知道你的具体情况是否会出现这种情况,但在 IE7/IE8 以及你打算支持的任何其他旧浏览器中尤其需要检查一下。
You may have to watch out for memory leaks in some browsers, particularly older ones. Lots of DOM manipulation is one place where some older browsers had leaks. I don't know if your particular case would trip on this or not, but it is something to check out in IE7/IE8 in particular and any other old browser you intend to support.
每秒的 HTTP 请求太多了!数据实际更改的频率是多少?更好地实现长池/Comet
HTTP request each second is too much! How often the data is actually changed? Better implement long pooling / Comet