is there any harmful effects of loading page often by using jquery?
<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 ?开发者_运维知识库
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
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.
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 request each second is too much! How often the data is actually changed? Better implement long pooling / Comet
精彩评论